What is the current behavior?
When GSAIKinematicBody2DAgent is outside of the main scene tree, it continues to try and update itself. Since it is not in the scene tree, this results in calls to global_position returning the local transform instead of the global transform, and this messes up velocity calculations when the agent is reinserted into the scene tree.
Observed this with the 2D agent, but the bug would be present for a 3D agent as well (both Kinematic and Rigid).
What is the expected behavior?
Agents should not try to update themselves if they are outside of the scene tree.
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
Create three scenes: one scene containing a GSAIKinematicBody2DAgent, one without the agent, and a third scene that toggles which of the previous two scenes is currently loaded. Start the game with the scene containing the agent and observe it trying to move; then switch to the scene without the agent; then switch back.
You should observe the agent starts from zero velocity; this is due to having used local transforms to try and calculate its velocity, resulting in reducing the internal velocity to zero.
Other
I already know how to fix this bug, just reporting this as an issue for documentation's sake before I pull the repo locally to make the fix.
I'm submitting a...
Bug report
What is the current behavior? When GSAIKinematicBody2DAgent is outside of the main scene tree, it continues to try and update itself. Since it is not in the scene tree, this results in calls to
global_position
returning the local transform instead of the global transform, and this messes up velocity calculations when the agent is reinserted into the scene tree.Observed this with the 2D agent, but the bug would be present for a 3D agent as well (both Kinematic and Rigid).
What is the expected behavior? Agents should not try to update themselves if they are outside of the scene tree.
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem. Create three scenes: one scene containing a GSAIKinematicBody2DAgent, one without the agent, and a third scene that toggles which of the previous two scenes is currently loaded. Start the game with the scene containing the agent and observe it trying to move; then switch to the scene without the agent; then switch back.
You should observe the agent starts from zero velocity; this is due to having used local transforms to try and calculate its velocity, resulting in reducing the internal velocity to zero.
Other
I already know how to fix this bug, just reporting this as an issue for documentation's sake before I pull the repo locally to make the fix.