godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.76k stars 21.13k forks source link

PathFollow2D does not update child AnimatableBody2D's collision #63140

Open illBeRoy opened 2 years ago

illBeRoy commented 2 years ago

Godot version

4.0.alpha11

System information

M1 MBP, MacOS Monterey

Issue description

When nesting an AnimatableBody2D under a PathFollow2D, and changing the offset of the PathFollow node, the AnimatableBody node moves along the path, but the collision for that node stays at the origin.

For instance, take this scene: image

And let's run it with paths and collision shapes visible: image

As you can see, the animatable body and its child collision shape move along, but the collision detection still uses the origin point as where the platform really is.

Workaround

After updating the PathFollow2D offset, set the position of the AnimatableBody2D to itself: image

Now the engine recognizes the new location of the collision shape, and updates accordingly: image

Steps to reproduce

First, create a tree similar that contains a Path2D, PathFollow2D and a fully configured AnimatableBody2D: image

Move the PathFollow2D node along the path using offset: image

The collision of the AnimatableBody2D node did not update according to its new location.

Step to workaround

Right after you update the offset, assign the body's own global_position to iself. Now the collision is updated: image

Minimal reproduction project

No response

Calinou commented 2 years ago

@illBeRoy Please upload a minimal reproduction project to make this easier to troubleshoot.

AttackButton commented 2 years ago

By the description, this is related with: https://github.com/godotengine/godot/issues/58269

hawkerm commented 1 year ago

Agree, seems like a duplicate of #58269, that issue mentions a workaround which does seem to work at the moment.