Stop agents from processing when they are outside of the scene tree (#55)

This commit is contained in:
Josh Anthony 2021-09-02 09:44:08 -05:00 committed by GitHub
parent 53cad0f660
commit 22dc7c751a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 0 deletions

View File

@ -50,6 +50,9 @@ func _apply_sliding_steering(accel: Vector3, delta: float) -> void:
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:
velocity = velocity.linear_interpolate(Vector2.ZERO, linear_drag_percentage)

View File

@ -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

View File

@ -51,6 +51,9 @@ func _on_SceneTree_frame() -> void:
if not _body:
return
if not _body.is_inside_tree():
return
var current_position := _body.global_position
var current_orientation := _body.rotation

View File

@ -50,6 +50,9 @@ func _on_SceneTree_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