diff --git a/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd b/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd index 18f8a11..c422e8f 100644 --- a/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd +++ b/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd @@ -49,6 +49,9 @@ func _apply_sliding_steering(accel: Vector3, delta: float) -> void: var _body: KinematicBody2D = _body_ref.get_ref() if not _body: return + + if not _body.is_inside_tree(): + return var velocity := GSAIUtils.to_vector2(linear_velocity + accel * delta).clamped(linear_speed_max) if apply_linear_drag: diff --git a/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd b/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd index 89bb5a3..ddc556b 100644 --- a/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd +++ b/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd @@ -132,6 +132,9 @@ func _on_SceneTree_physics_frame() -> void: if not _body: return + if not _body.is_inside_tree(): + return + var current_position := _body.transform.origin var current_orientation := _body.rotation.y diff --git a/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd b/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd index 71ecd54..763ae65 100644 --- a/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd +++ b/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd @@ -50,6 +50,9 @@ func _on_SceneTree_frame() -> void: var _body: RigidBody2D = _body_ref.get_ref() if not _body: return + + if not _body.is_inside_tree(): + return var current_position := _body.global_position var current_orientation := _body.rotation diff --git a/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd b/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd index ad8e52b..bc26959 100644 --- a/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd +++ b/godot/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd @@ -49,6 +49,9 @@ func _on_SceneTree_frame() -> void: var _body: RigidBody = _body_ref.get_ref() if not _body: return + + if not _body.is_inside_tree(): + return var current_position := _body.transform.origin var current_orientation := _body.rotation.y