Removed yields from the agents.

This commit is contained in:
Relintai 2023-01-13 17:11:52 +01:00
parent 2236e48f45
commit 3957f155da
4 changed files with 28 additions and 14 deletions

View File

@ -24,14 +24,17 @@ var _body_ref : WeakRef
func _init(_body: KinematicBody2D, _movement_type: int = MovementType.SLIDE) -> void:
if !_body.is_inside_tree():
yield(_body, "ready")
self.body = _body
self.movement_type = _movement_type
if !_body.is_inside_tree():
_body.connect("ready", self, "_body_ready")
else:
_body_ready()
func _body_ready() -> void:
# warning-ignore:return_value_discarded
_body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
# Moves the agent's `body` by target `acceleration`.

View File

@ -24,14 +24,17 @@ var _body_ref : WeakRef
func _init(_body: KinematicBody, _movement_type: int = MovementType.SLIDE) -> void:
if !_body.is_inside_tree():
yield(_body, "ready")
self.body = _body
self.movement_type = _movement_type
if !_body.is_inside_tree():
_body.connect("ready", self, "_body_ready")
else:
_body_ready()
func _body_ready() -> void:
# warning-ignore:return_value_discarded
_body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
# Moves the agent's `body` by target `acceleration`.

View File

@ -12,12 +12,16 @@ var _body_ref : WeakRef
func _init(_body : RigidBody2D) -> void:
if not _body.is_inside_tree():
yield(_body, "ready")
self.body = _body
if !_body.is_inside_tree():
_body.connect("ready", self, "_body_ready")
else:
_body_ready()
func _body_ready() -> void:
# warning-ignore:return_value_discarded
_body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
# Moves the agent's `body` by target `acceleration`.

View File

@ -11,12 +11,16 @@ var _last_position: Vector3
var _body_ref: WeakRef
func _init(_body: RigidBody) -> void:
if not _body.is_inside_tree():
yield(_body, "ready")
self.body = _body
if !_body.is_inside_tree():
_body.connect("ready", self, "_body_ready")
else:
_body_ready()
func _body_ready() -> void:
# warning-ignore:return_value_discarded
_body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
# Moves the agent's `body` by target `acceleration`.