Fix spec. agents at position 0,0,0 on first frame

This commit is contained in:
Francois Belair 2020-05-24 13:00:40 -04:00
parent ca1a7088c5
commit 4d4c7213ba
5 changed files with 5 additions and 7 deletions

View File

@ -15,6 +15,7 @@ This document lists new features, improvements, changes, and bug fixes in every
- KinematicBody2DAgents and KinematicBody3DAgents that moved fast enough no longer reverse velocity suddenly during a frame where no acceleration is applied.
- Specialized Agents like RigidBody2DAgent should no longer crash due to a missing reference.
- Specialized physics agents no longer believe they are at 0,0,0 on the first frame.
## Godot Steering AI Framework 2.1.0

View File

@ -23,7 +23,7 @@ func _init(_body: KinematicBody2D, _movement_type: int = MovementType.SLIDE) ->
if not _body.is_inside_tree():
yield(_body, "ready")
_body_ref = weakref(_body)
self.body = _body
self.movement_type = _movement_type
# warning-ignore:return_value_discarded

View File

@ -20,11 +20,10 @@ var _body_ref: WeakRef
func _init(_body: KinematicBody, _movement_type: int = MovementType.SLIDE) -> void:
body = _body
if not _body.is_inside_tree():
yield(_body, "ready")
self._body_ref = weakref(_body)
self.body = _body
self.movement_type = _movement_type
# warning-ignore:return_value_discarded

View File

@ -12,11 +12,10 @@ var _body_ref: WeakRef
func _init(_body: RigidBody2D) -> void:
body = _body
if not _body.is_inside_tree():
yield(_body, "ready")
self.body = _body
_body_ref = weakref(_body)
# warning-ignore:return_value_discarded
_body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")

View File

@ -11,11 +11,10 @@ var _last_position: Vector3
var _body_ref: WeakRef
func _init(_body: RigidBody) -> void:
body = _body
if not _body.is_inside_tree():
yield(_body, "ready")
self.body = _body
_body_ref = weakref(_body)
# warning-ignore:return_value_discarded
_body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")