mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2024-11-18 09:07:18 +01:00
Updated the engine. Now it has agents built in aswell.
This commit is contained in:
parent
0c863b099d
commit
111a729eb8
2
HEADS
2
HEADS
@ -1 +1 @@
|
|||||||
{"engine": {"3.2": "94a0fc47f7b4e90f8973f9adbfd3312579ed2825", "master": "8c73e813134001e575b6f59e3b0100471c007410", "3.x": "c4864a0e5f73a375259503ea1485794a6aad6df7"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "3536f01bacf5f54cefb32b768cd020a1f94d0ade"}, "ui_extensions": {"master": "80a3b96fc56991a0f88a1d441ed1e3cebaf3307a"}, "voxelman": {"master": "65485930a20f65844d496b4ba47dec5b6ed70b91"}, "texture_packer": {"master": "ae4d222fbaade063ed6f0bc9f3aaa53df68a7fed"}, "fastnoise": {"master": "46bb1f610bfb7171613b5c708d312bcf94e89356"}, "mesh_data_resource": {"master": "a062d871d49d954c5466b9de54b4075cb61cbef4"}, "procedural_animations": {"master": "f8aae42bf06b3936cc6bd24cb18e1c3ec9f78f4f"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "983090d21a08ebed30a5ce06681269819ab12e48"}, "mesh_utils": {"master": "b52a261c31f04fad624e5cfbcdcc4a45d61136da"}, "broken_seals_module": {"master": "52c5a81350db1c29d375c63d95010260911ec034"}, "thread_pool": {"master": "0917511d04bb1aa308385b63ec88d3c182990628"}, "terraman": {"master": "c72d8fc03295588fc18c5168ce351bd0c321ec5f"}, "pandemonium_engine": {"master": "caf3f1210b6d759065a6e2fceeab4cb31ba1c683"}}
|
{"engine": {"3.2": "94a0fc47f7b4e90f8973f9adbfd3312579ed2825", "master": "8c73e813134001e575b6f59e3b0100471c007410", "3.x": "c4864a0e5f73a375259503ea1485794a6aad6df7"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "3536f01bacf5f54cefb32b768cd020a1f94d0ade"}, "ui_extensions": {"master": "80a3b96fc56991a0f88a1d441ed1e3cebaf3307a"}, "voxelman": {"master": "65485930a20f65844d496b4ba47dec5b6ed70b91"}, "texture_packer": {"master": "ae4d222fbaade063ed6f0bc9f3aaa53df68a7fed"}, "fastnoise": {"master": "46bb1f610bfb7171613b5c708d312bcf94e89356"}, "mesh_data_resource": {"master": "a062d871d49d954c5466b9de54b4075cb61cbef4"}, "procedural_animations": {"master": "f8aae42bf06b3936cc6bd24cb18e1c3ec9f78f4f"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "983090d21a08ebed30a5ce06681269819ab12e48"}, "mesh_utils": {"master": "b52a261c31f04fad624e5cfbcdcc4a45d61136da"}, "broken_seals_module": {"master": "52c5a81350db1c29d375c63d95010260911ec034"}, "thread_pool": {"master": "0917511d04bb1aa308385b63ec88d3c182990628"}, "terraman": {"master": "c72d8fc03295588fc18c5168ce351bd0c321ec5f"}, "pandemonium_engine": {"master": "3be6c6282c39639914a4da8f0a8c608b47cb61e2"}}
|
@ -1,164 +0,0 @@
|
|||||||
extends GSAISpecializedAgent
|
|
||||||
class_name GSAIKinematicBody2DAgent
|
|
||||||
|
|
||||||
# A specialized steering agent that updates itself every frame so the user does
|
|
||||||
# not have to using a KinematicBody2D
|
|
||||||
# @category - Specialized agents
|
|
||||||
|
|
||||||
# SLIDE uses `move_and_slide`
|
|
||||||
# COLLIDE uses `move_and_collide`
|
|
||||||
# POSITION changes the `global_position` directly
|
|
||||||
enum MovementType {
|
|
||||||
SLIDE,
|
|
||||||
COLLIDE,
|
|
||||||
POSITION
|
|
||||||
}
|
|
||||||
|
|
||||||
# The KinematicBody2D to keep track of
|
|
||||||
var body: KinematicBody2D setget _set_body
|
|
||||||
|
|
||||||
# The type of movement the body executes
|
|
||||||
var movement_type : int = MovementType.SLIDE
|
|
||||||
|
|
||||||
var _last_position : Vector2
|
|
||||||
var _body_ref : WeakRef
|
|
||||||
|
|
||||||
|
|
||||||
func _body_ready() -> void:
|
|
||||||
# warning-ignore:return_value_discarded
|
|
||||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
|
|
||||||
|
|
||||||
|
|
||||||
# Moves the agent's `body` by target `acceleration`.
|
|
||||||
# @tags - virtual
|
|
||||||
func _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void:
|
|
||||||
applied_steering = true
|
|
||||||
|
|
||||||
if movement_type == MovementType.COLLIDE:
|
|
||||||
_apply_collide_steering(acceleration.linear, delta)
|
|
||||||
elif movement_type == MovementType.SLIDE:
|
|
||||||
_apply_sliding_steering(acceleration.linear, delta)
|
|
||||||
else:
|
|
||||||
_apply_position_steering(acceleration.linear, delta)
|
|
||||||
|
|
||||||
_apply_orientation_steering(acceleration.angular, delta)
|
|
||||||
|
|
||||||
|
|
||||||
func _apply_sliding_steering(accel: Vector3, delta: float) -> void:
|
|
||||||
var _body: KinematicBody2D = _body_ref.get_ref()
|
|
||||||
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
if !_body.is_inside_tree() or _body.get_tree().paused:
|
|
||||||
return
|
|
||||||
|
|
||||||
var velocity : Vector2 = GSAIUtils.to_vector2(linear_velocity + accel * delta).limit_length(linear_speed_max)
|
|
||||||
|
|
||||||
if apply_linear_drag:
|
|
||||||
velocity = velocity.linear_interpolate(Vector2.ZERO, linear_drag_percentage)
|
|
||||||
|
|
||||||
velocity = _body.move_and_slide(velocity)
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
linear_velocity = GSAIUtils.to_vector3(velocity)
|
|
||||||
|
|
||||||
|
|
||||||
func _apply_collide_steering(accel: Vector3, delta: float) -> void:
|
|
||||||
var _body: KinematicBody2D = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
var velocity : Vector3 = GSAIUtils.clampedv3(linear_velocity + accel * delta, linear_speed_max)
|
|
||||||
if apply_linear_drag:
|
|
||||||
velocity = velocity.linear_interpolate(Vector3.ZERO, linear_drag_percentage)
|
|
||||||
|
|
||||||
# warning-ignore:return_value_discarded
|
|
||||||
_body.move_and_collide(GSAIUtils.to_vector2(velocity) * delta)
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
linear_velocity = velocity
|
|
||||||
|
|
||||||
|
|
||||||
func _apply_position_steering(accel: Vector3, delta: float) -> void:
|
|
||||||
var _body: KinematicBody2D = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
var velocity : Vector3 = GSAIUtils.clampedv3(linear_velocity + accel * delta, linear_speed_max)
|
|
||||||
|
|
||||||
if apply_linear_drag:
|
|
||||||
velocity = velocity.linear_interpolate(Vector3.ZERO, linear_drag_percentage)
|
|
||||||
|
|
||||||
_body.global_position += GSAIUtils.to_vector2(velocity) * delta
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
linear_velocity = velocity
|
|
||||||
|
|
||||||
|
|
||||||
func _apply_orientation_steering(angular_acceleration: float, delta: float) -> void:
|
|
||||||
var _body: KinematicBody2D = _body_ref.get_ref()
|
|
||||||
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
var velocity = clamp(angular_velocity + angular_acceleration * delta, -angular_speed_max, angular_speed_max)
|
|
||||||
|
|
||||||
if apply_angular_drag:
|
|
||||||
velocity = lerp(velocity, 0, angular_drag_percentage)
|
|
||||||
|
|
||||||
_body.rotation += velocity * delta
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
angular_velocity = velocity
|
|
||||||
|
|
||||||
|
|
||||||
func _set_body(value: KinematicBody2D) -> void:
|
|
||||||
var had_body : bool = false
|
|
||||||
|
|
||||||
if body:
|
|
||||||
had_body = true
|
|
||||||
|
|
||||||
body = value
|
|
||||||
_body_ref = weakref(body)
|
|
||||||
|
|
||||||
_last_position = value.global_position
|
|
||||||
last_orientation = value.rotation
|
|
||||||
|
|
||||||
position = GSAIUtils.to_vector3(_last_position)
|
|
||||||
orientation = last_orientation
|
|
||||||
|
|
||||||
if !had_body:
|
|
||||||
if !body.is_inside_tree():
|
|
||||||
body.connect("ready", self, "_body_ready")
|
|
||||||
else:
|
|
||||||
_body_ready()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_SceneTree_physics_frame() -> void:
|
|
||||||
var _body: KinematicBody2D = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
var current_position : Vector2 = _body.global_position
|
|
||||||
var current_orientation : float = _body.rotation
|
|
||||||
|
|
||||||
position = GSAIUtils.to_vector3(current_position)
|
|
||||||
orientation = current_orientation
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
if applied_steering:
|
|
||||||
applied_steering = false
|
|
||||||
else:
|
|
||||||
linear_velocity = GSAIUtils.clampedv3(GSAIUtils.to_vector3(current_position - _last_position), linear_speed_max)
|
|
||||||
|
|
||||||
if apply_linear_drag:
|
|
||||||
linear_velocity = linear_velocity.linear_interpolate(Vector3.ZERO, linear_drag_percentage)
|
|
||||||
|
|
||||||
angular_velocity = clamp(last_orientation - current_orientation, -angular_speed_max, angular_speed_max)
|
|
||||||
|
|
||||||
if apply_angular_drag:
|
|
||||||
angular_velocity = lerp(angular_velocity, 0, angular_drag_percentage)
|
|
||||||
|
|
||||||
_last_position = current_position
|
|
||||||
last_orientation = current_orientation
|
|
@ -1,160 +0,0 @@
|
|||||||
extends GSAISpecializedAgent
|
|
||||||
class_name GSAIKinematicBody3DAgent
|
|
||||||
|
|
||||||
# A specialized steering agent that updates itself every frame so the user does
|
|
||||||
# not have to using a KinematicBody
|
|
||||||
# @category - Specialized agents
|
|
||||||
|
|
||||||
# SLIDE uses `move_and_slide`
|
|
||||||
# COLLIDE uses `move_and_collide`
|
|
||||||
# POSITION changes the global_position directly
|
|
||||||
enum MovementType {
|
|
||||||
SLIDE,
|
|
||||||
COLLIDE,
|
|
||||||
POSITION
|
|
||||||
}
|
|
||||||
|
|
||||||
# The KinematicBody to keep track of
|
|
||||||
var body : KinematicBody setget _set_body
|
|
||||||
|
|
||||||
# The type of movement the body executes
|
|
||||||
var movement_type : int = 0
|
|
||||||
|
|
||||||
var _last_position : Vector3
|
|
||||||
var _body_ref : WeakRef
|
|
||||||
|
|
||||||
|
|
||||||
func _body_ready() -> void:
|
|
||||||
# warning-ignore:return_value_discarded
|
|
||||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
|
|
||||||
|
|
||||||
|
|
||||||
# Moves the agent's `body` by target `acceleration`.
|
|
||||||
# @tags - virtual
|
|
||||||
func _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void:
|
|
||||||
applied_steering = true
|
|
||||||
if movement_type == MovementType.COLLIDE:
|
|
||||||
_apply_collide_steering(acceleration.linear, delta)
|
|
||||||
elif movement_type == MovementType.SLIDE:
|
|
||||||
_apply_sliding_steering(acceleration.linear, delta)
|
|
||||||
else:
|
|
||||||
_apply_position_steering(acceleration.linear, delta)
|
|
||||||
|
|
||||||
_apply_orientation_steering(acceleration.angular, delta)
|
|
||||||
|
|
||||||
|
|
||||||
func _apply_sliding_steering(accel: Vector3, delta: float) -> void:
|
|
||||||
var _body: KinematicBody = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
var velocity : Vector3 = GSAIUtils.clampedv3(linear_velocity + accel * delta, linear_speed_max)
|
|
||||||
|
|
||||||
if apply_linear_drag:
|
|
||||||
velocity = velocity.linear_interpolate(Vector3.ZERO, linear_drag_percentage)
|
|
||||||
|
|
||||||
velocity = _body.move_and_slide(velocity)
|
|
||||||
if calculate_velocities:
|
|
||||||
linear_velocity = velocity
|
|
||||||
|
|
||||||
|
|
||||||
func _apply_collide_steering(accel: Vector3, delta: float) -> void:
|
|
||||||
var _body: KinematicBody = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
var velocity : Vector3 = GSAIUtils.clampedv3(linear_velocity + accel * delta, linear_speed_max)
|
|
||||||
|
|
||||||
if apply_linear_drag:
|
|
||||||
velocity = velocity.linear_interpolate(Vector3.ZERO, linear_drag_percentage)
|
|
||||||
|
|
||||||
# warning-ignore:return_value_discarded
|
|
||||||
_body.move_and_collide(velocity * delta)
|
|
||||||
if calculate_velocities:
|
|
||||||
linear_velocity = velocity
|
|
||||||
|
|
||||||
|
|
||||||
func _apply_position_steering(accel: Vector3, delta: float) -> void:
|
|
||||||
var _body: KinematicBody = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
var velocity : Vector3 = GSAIUtils.clampedv3(linear_velocity + accel * delta, linear_speed_max)
|
|
||||||
|
|
||||||
if apply_linear_drag:
|
|
||||||
velocity = velocity.linear_interpolate(Vector3.ZERO, linear_drag_percentage)
|
|
||||||
|
|
||||||
_body.global_transform.origin += velocity * delta
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
linear_velocity = velocity
|
|
||||||
|
|
||||||
|
|
||||||
func _apply_orientation_steering(angular_acceleration: float, delta: float) -> void:
|
|
||||||
var _body: KinematicBody = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
var velocity = clamp(angular_velocity + angular_acceleration * delta,-angular_speed_max,angular_speed_max)
|
|
||||||
|
|
||||||
if apply_angular_drag:
|
|
||||||
velocity = lerp(velocity, 0, angular_drag_percentage)
|
|
||||||
|
|
||||||
_body.rotation.y += velocity * delta
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
angular_velocity = velocity
|
|
||||||
|
|
||||||
|
|
||||||
func _set_body(value: KinematicBody) -> void:
|
|
||||||
var had_body : bool = false
|
|
||||||
|
|
||||||
if body:
|
|
||||||
had_body = true
|
|
||||||
|
|
||||||
body = value
|
|
||||||
_body_ref = weakref(value)
|
|
||||||
|
|
||||||
_last_position = value.transform.origin
|
|
||||||
last_orientation = value.rotation.y
|
|
||||||
|
|
||||||
position = _last_position
|
|
||||||
orientation = last_orientation
|
|
||||||
|
|
||||||
if !had_body:
|
|
||||||
if !body.is_inside_tree():
|
|
||||||
body.connect("ready", self, "_body_ready")
|
|
||||||
else:
|
|
||||||
_body_ready()
|
|
||||||
|
|
||||||
func _on_SceneTree_physics_frame() -> void:
|
|
||||||
var _body : KinematicBody = _body_ref.get_ref()
|
|
||||||
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
if !_body.is_inside_tree() || _body.get_tree().paused:
|
|
||||||
return
|
|
||||||
|
|
||||||
var current_position : Vector3 = _body.transform.origin
|
|
||||||
var current_orientation : float = _body.rotation.y
|
|
||||||
|
|
||||||
position = current_position
|
|
||||||
orientation = current_orientation
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
if applied_steering:
|
|
||||||
applied_steering = false
|
|
||||||
else:
|
|
||||||
linear_velocity = GSAIUtils.clampedv3(current_position - _last_position, linear_speed_max)
|
|
||||||
|
|
||||||
if apply_linear_drag:
|
|
||||||
linear_velocity = linear_velocity.linear_interpolate(Vector3.ZERO, linear_drag_percentage)
|
|
||||||
|
|
||||||
angular_velocity = clamp(last_orientation - current_orientation,-angular_speed_max,angular_speed_max)
|
|
||||||
|
|
||||||
if apply_angular_drag:
|
|
||||||
angular_velocity = lerp(angular_velocity, 0, angular_drag_percentage)
|
|
||||||
|
|
||||||
_last_position = current_position
|
|
||||||
last_orientation = current_orientation
|
|
@ -1,76 +0,0 @@
|
|||||||
extends GSAISpecializedAgent
|
|
||||||
class_name GSAIRigidBody2DAgent
|
|
||||||
|
|
||||||
# A specialized steering agent that updates itself every frame so the user does
|
|
||||||
# not have to using a RigidBody2D
|
|
||||||
# @category - Specialized agents
|
|
||||||
|
|
||||||
# The RigidBody2D to keep track of
|
|
||||||
var body : RigidBody2D setget _set_body
|
|
||||||
|
|
||||||
var _last_position : Vector2
|
|
||||||
var _body_ref : WeakRef
|
|
||||||
|
|
||||||
|
|
||||||
func _body_ready() -> void:
|
|
||||||
# warning-ignore:return_value_discarded
|
|
||||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
|
|
||||||
|
|
||||||
|
|
||||||
# Moves the agent's `body` by target `acceleration`.
|
|
||||||
# @tags - virtual
|
|
||||||
func _apply_steering(acceleration : GSAITargetAcceleration, _delta : float) -> void:
|
|
||||||
var _body: RigidBody2D = _body_ref.get_ref()
|
|
||||||
if not _body:
|
|
||||||
return
|
|
||||||
|
|
||||||
applied_steering = true
|
|
||||||
_body.apply_central_impulse(GSAIUtils.to_vector2(acceleration.linear))
|
|
||||||
_body.apply_torque_impulse(acceleration.angular)
|
|
||||||
if calculate_velocities:
|
|
||||||
linear_velocity = GSAIUtils.to_vector3(_body.linear_velocity)
|
|
||||||
angular_velocity = _body.angular_velocity
|
|
||||||
|
|
||||||
|
|
||||||
func _set_body(value: RigidBody2D) -> void:
|
|
||||||
var had_body : bool = false
|
|
||||||
|
|
||||||
if body:
|
|
||||||
had_body = true
|
|
||||||
|
|
||||||
body = value
|
|
||||||
_body_ref = weakref(value)
|
|
||||||
|
|
||||||
_last_position = value.global_position
|
|
||||||
last_orientation = value.rotation
|
|
||||||
|
|
||||||
position = GSAIUtils.to_vector3(_last_position)
|
|
||||||
orientation = last_orientation
|
|
||||||
|
|
||||||
if !had_body:
|
|
||||||
if !body.is_inside_tree():
|
|
||||||
body.connect("ready", self, "_body_ready")
|
|
||||||
else:
|
|
||||||
_body_ready()
|
|
||||||
|
|
||||||
|
|
||||||
func _on_SceneTree_frame() -> void:
|
|
||||||
var _body: RigidBody2D = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
if !_body.is_inside_tree() or _body.get_tree().paused:
|
|
||||||
return
|
|
||||||
|
|
||||||
var current_position : Vector2 = _body.global_position
|
|
||||||
var current_orientation : float = _body.rotation
|
|
||||||
|
|
||||||
position = GSAIUtils.to_vector3(current_position)
|
|
||||||
orientation = current_orientation
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
if applied_steering:
|
|
||||||
applied_steering = false
|
|
||||||
else:
|
|
||||||
linear_velocity = GSAIUtils.to_vector3(_body.linear_velocity)
|
|
||||||
angular_velocity = _body.angular_velocity
|
|
@ -1,74 +0,0 @@
|
|||||||
extends GSAISpecializedAgent
|
|
||||||
class_name GSAIRigidBody3DAgent
|
|
||||||
|
|
||||||
# A specialized steering agent that updates itself every frame so the user does
|
|
||||||
# not have to using a RigidBody
|
|
||||||
# @category - Specialized agents
|
|
||||||
|
|
||||||
# The RigidBody to keep track of
|
|
||||||
var body: RigidBody setget _set_body
|
|
||||||
|
|
||||||
var _last_position: Vector3
|
|
||||||
var _body_ref: WeakRef
|
|
||||||
|
|
||||||
func _body_ready() -> void:
|
|
||||||
# warning-ignore:return_value_discarded
|
|
||||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
|
|
||||||
|
|
||||||
|
|
||||||
# Moves the agent's `body` by target `acceleration`.
|
|
||||||
# @tags - virtual
|
|
||||||
func _apply_steering(acceleration: GSAITargetAcceleration, _delta: float) -> void:
|
|
||||||
var _body: RigidBody = _body_ref.get_ref()
|
|
||||||
if !_body:
|
|
||||||
return
|
|
||||||
|
|
||||||
applied_steering = true
|
|
||||||
_body.apply_central_impulse(acceleration.linear)
|
|
||||||
_body.apply_torque_impulse(Vector3.UP * acceleration.angular)
|
|
||||||
if calculate_velocities:
|
|
||||||
linear_velocity = _body.linear_velocity
|
|
||||||
angular_velocity = _body.angular_velocity.y
|
|
||||||
|
|
||||||
|
|
||||||
func _set_body(value: RigidBody) -> void:
|
|
||||||
var had_body : bool = false
|
|
||||||
|
|
||||||
if body:
|
|
||||||
had_body = true
|
|
||||||
|
|
||||||
body = value
|
|
||||||
_body_ref = weakref(value)
|
|
||||||
|
|
||||||
_last_position = value.transform.origin
|
|
||||||
last_orientation = value.rotation.y
|
|
||||||
|
|
||||||
position = _last_position
|
|
||||||
orientation = last_orientation
|
|
||||||
|
|
||||||
if !had_body:
|
|
||||||
if !body.is_inside_tree():
|
|
||||||
body.connect("ready", self, "_body_ready")
|
|
||||||
else:
|
|
||||||
_body_ready()
|
|
||||||
|
|
||||||
func _on_SceneTree_frame() -> void:
|
|
||||||
var _body: RigidBody = _body_ref.get_ref()
|
|
||||||
if not _body:
|
|
||||||
return
|
|
||||||
|
|
||||||
if not _body.is_inside_tree() or _body.get_tree().paused:
|
|
||||||
return
|
|
||||||
|
|
||||||
var current_position : Vector3 = _body.transform.origin
|
|
||||||
var current_orientation : float = _body.rotation.y
|
|
||||||
|
|
||||||
position = current_position
|
|
||||||
orientation = current_orientation
|
|
||||||
|
|
||||||
if calculate_velocities:
|
|
||||||
if applied_steering:
|
|
||||||
applied_steering = false
|
|
||||||
else:
|
|
||||||
linear_velocity = _body.linear_velocity
|
|
||||||
angular_velocity = _body.angular_velocity.y
|
|
@ -1,42 +0,0 @@
|
|||||||
extends GSAISteeringAgent
|
|
||||||
class_name GSAISpecializedAgent
|
|
||||||
|
|
||||||
# A base class for a specialized steering agent that updates itself every frame
|
|
||||||
# so the user does not have to. All other specialized agents derive from this.
|
|
||||||
# @category - Specialized agents
|
|
||||||
# @tags - abstract
|
|
||||||
|
|
||||||
# If `true`, calculates linear and angular velocities based on the previous
|
|
||||||
# frame. When `false`, the user must keep those values updated.
|
|
||||||
var calculate_velocities : bool = true
|
|
||||||
|
|
||||||
# If `true`, interpolates the current linear velocity towards 0 by the
|
|
||||||
# `linear_drag_percentage` value.
|
|
||||||
# Does not apply to `RigidBody` and `RigidBody2D` nodes.
|
|
||||||
var apply_linear_drag : bool = true
|
|
||||||
|
|
||||||
# If `true`, interpolates the current angular velocity towards 0 by the
|
|
||||||
# `angular_drag_percentage` value.
|
|
||||||
# Does not apply to `RigidBody` and `RigidBody2D` nodes.
|
|
||||||
var apply_angular_drag : bool = true
|
|
||||||
|
|
||||||
# The percentage between the current linear velocity and 0 to interpolate by if
|
|
||||||
# `apply_linear_drag` is true.
|
|
||||||
# Does not apply to `RigidBody` and `RigidBody2D` nodes.
|
|
||||||
var linear_drag_percentage : float = 0.0
|
|
||||||
|
|
||||||
# The percentage between the current angular velocity and 0 to interpolate by if
|
|
||||||
# `apply_angular_drag` is true.
|
|
||||||
# Does not apply to `RigidBody` and `RigidBody2D` nodes.
|
|
||||||
var angular_drag_percentage : float = 0.0
|
|
||||||
|
|
||||||
var last_orientation : float = 0.0
|
|
||||||
var applied_steering : bool = false
|
|
||||||
|
|
||||||
func apply_steering(_acceleration : GSAITargetAcceleration, _delta : float) -> void:
|
|
||||||
call("_apply_steering", _acceleration, _delta)
|
|
||||||
|
|
||||||
# Moves the agent's body by target `acceleration`.
|
|
||||||
# @tags - virtual
|
|
||||||
func _apply_steering(_acceleration : GSAITargetAcceleration, _delta : float) -> void:
|
|
||||||
pass
|
|
@ -13,38 +13,8 @@ _global_script_classes=[ {
|
|||||||
"class": @"DemoPickerUI",
|
"class": @"DemoPickerUI",
|
||||||
"language": @"GDScript",
|
"language": @"GDScript",
|
||||||
"path": "res://Demos/DemoPickerUI.gd"
|
"path": "res://Demos/DemoPickerUI.gd"
|
||||||
}, {
|
|
||||||
"base": "GSAISpecializedAgent",
|
|
||||||
"class": @"GSAIKinematicBody2DAgent",
|
|
||||||
"language": @"GDScript",
|
|
||||||
"path": "res://addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd"
|
|
||||||
}, {
|
|
||||||
"base": "GSAISpecializedAgent",
|
|
||||||
"class": @"GSAIKinematicBody3DAgent",
|
|
||||||
"language": @"GDScript",
|
|
||||||
"path": "res://addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd"
|
|
||||||
}, {
|
|
||||||
"base": "GSAISpecializedAgent",
|
|
||||||
"class": @"GSAIRigidBody2DAgent",
|
|
||||||
"language": @"GDScript",
|
|
||||||
"path": "res://addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd"
|
|
||||||
}, {
|
|
||||||
"base": "GSAISpecializedAgent",
|
|
||||||
"class": @"GSAIRigidBody3DAgent",
|
|
||||||
"language": @"GDScript",
|
|
||||||
"path": "res://addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd"
|
|
||||||
}, {
|
|
||||||
"base": "GSAISteeringAgent",
|
|
||||||
"class": @"GSAISpecializedAgent",
|
|
||||||
"language": @"GDScript",
|
|
||||||
"path": "res://addons/com.gdquest.godot-steering-ai-framework/Agents/GSAISpecializedAgent.gd"
|
|
||||||
} ]
|
} ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
@"GSAIKinematicBody2DAgent": "",
|
|
||||||
@"GSAIKinematicBody3DAgent": "",
|
|
||||||
@"GSAIRigidBody2DAgent": "",
|
|
||||||
@"GSAIRigidBody3DAgent": "",
|
|
||||||
@"GSAISpecializedAgent": "",
|
|
||||||
@"DemoPickerUI": ""
|
@"DemoPickerUI": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user