0 votes

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.

in Engine by (662 points)

2 Answers

+1 vote
Best answer

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.

by (7,832 points)
selected by
+1 vote

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

by (206 points)

Probably, thank you!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.