From 4d4c7213ba85f55573243a21979e348f306d2f93 Mon Sep 17 00:00:00 2001 From: Francois Belair Date: Sun, 24 May 2020 13:00:40 -0400 Subject: [PATCH] Fix spec. agents at position 0,0,0 on first frame --- CHANGELOG.md | 1 + .../Agents/GSAIKinematicBody2DAgent.gd | 2 +- .../Agents/GSAIKinematicBody3DAgent.gd | 3 +-- .../Agents/GSAIRigidBody2DAgent.gd | 3 +-- .../Agents/GSAIRigidBody3DAgent.gd | 3 +-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 964d2bb..10bbfad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd b/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd index a41c500..74318fe 100644 --- a/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd +++ b/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody2DAgent.gd @@ -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 diff --git a/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd b/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd index 11ab734..d406618 100644 --- a/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd +++ b/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIKinematicBody3DAgent.gd @@ -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 diff --git a/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd b/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd index 455a99b..71ecd54 100644 --- a/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd +++ b/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody2DAgent.gd @@ -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") diff --git a/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd b/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd index fcf7369..ad8e52b 100644 --- a/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd +++ b/addons/com.gdquest.godot-steering-ai-framework/Agents/GSAIRigidBody3DAgent.gd @@ -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")