Collisions not working if RigidBody2D is a child of a Node2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jarlowrey
:warning: Old Version Published before Godot 3 was released.

Originally I had my nodes setup as

Node2D
|-RigidBody2D
||-Sprite
||-CollisionShape2D

And collisions were not working, broken. I modified my scene so the RigidBody2D was the parent

-RigidBody2D
|-Sprite
|-CollisionShape2D

and everything is working fine now. Why is this? What’s going on here? When I made this change, I also had to use global rot, pos as it doesn’t seem to be inheriting from the parent anymore.

:bust_in_silhouette: Reply From: VitaZheltyakov

I have this structure and it works. Perhaps it is your code.

Probably, thank you!

jarlowrey | 2017-05-05 18:38

:bust_in_silhouette: Reply From: eons

If you don’t move the Node2D, RigidBody2D should work fine.

Also remember that rigid bodies are meant to be managed by the physics engine (Godot lets you manipulate velocities and add forces to them) and not touch them via transform (scale, rotate, translate) if you want it to work as it should on each physics frame.

This is why having the RB as root of a game entity’s branch is what makes more sense.