Collision Shape 2D not moving with parent RigidBody 2d Node & Collides with parent

Godot Version 4.2

Question: Why would a CollisionShape not Move with the Parent RigidBody? How do I fix this error?

After completing the tutorial “Your First Game” I wanted to try and make something simple, like Pong. Everything behaved as expected until I put everything together and… the ball simply went through the paddles.
I doublechecked

  • The paddle’s (Area2D) Monitoring property is on.
  • The paddle and ball (RigidBody2d) are on the same collision layer
  • Signals were properly connected

But I wasn’t getting any hits registered, and the ball was still moving through the paddle. In an attempt to get a better look at the problem, I allowed the paddle to move horizontally and discovered that the ball changes directions when the paddle moves through the center of the screen (where the ball originates at the start of the game):

Untitled video - Made with Clipchamp

And then:

In response to that, I attempted to ensure that the collision shape would follow the RigidBody object (the Ball) with the following statement:
$CollisionShape2D.position = position
in the script attached to the Ball object, which set the position of the collision shape equal to the position of the parent node. However, when I tested those changes, the ball didn’t move… adjusting the RigidBody’s mass properties (increasing mass) and changing the sleep mode of the collider made the ball vibrate intensely while remaining in place… leading me to believe the RigidBody was colliding with it’s child CollisionShape.

I have no idea what is going on, please send help
(On a serious note I will reply to any questions ASAP with more info)

I would appreciate your time and help, thank you

Replying to myself because I can’t add more than one media item per post…
Untitled video - Made with Clipchamp (1)
↑ Above is footage recorded with the $CollisionShape2D.position = position snippet added to the RigidBody’s attached script.

Setting the position (or velocity) of a RigidBody or its collision shape is not supported and should be avoided. You should use forces instead. The reason you’re not getting collisions is likely because the physics object is not where your visual instance is.

That indeed was the problem. I had no idea that was how Rigid bodies worked… thank you!

I chose to switch the ball to an Area 2D instead and change the signal to area_entered to be easier for my purposes…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.