Rigidbody2D behaves differently/broken when scene gets instantiated

Godot Version

v4.4.stable.official [4c311cbee]

Question

Hi everyone! =D
I am having a bizarre problem with my RigidBodies. I want to build a small chat system where the new messages get typed out on top and then fall down to the bottom. I figured out how to do this and it works well in the scene I have built this system (it’s not fluid bc I made a GIF from the recording):

works

Once the message is written I resize the CollisionShape to the size of the MarginContainer and unfreeze the RigidBody → Then the message falls.

Right when this happens I also reparent the RigidBody to a Node2D in order to sort of archive the message and make room for the next one. The code looks as follows:

func archiving():
	var shape = RectangleShape2D.new()
	current_frame.position = current_coat.position + current_coat.size / 2
	shape.size = current_coat.size
	current_frame.set_shape(shape)

	current_emotion.freeze = false
	current_emotion.reparent($archive, true)

Now when I access this whole event from my RootScene the physics don’t work at all anymore (I highlighted the CollisionShapes from the StaticBody that should keep the messages in place):
doesnt

As you can see it’s absolutely broken. I do know that something is up with the CollsionShapes of the RigidBodies because when I don’t resize them and keep them small it works!
Another issue that was happening was, that the Rigidbodies suddenly scaled to (2.8, 2.8) once they unfreezed in the latter example. I “fixed” this with telling the Rigidbodies to always keep being scaled to (1, 1) in the _physics_process.
I do move the RigidBodies position while they are frozen but once I unfreeze them I don’t manipulate them at all. So I think it does have something to do with resizing the CollisionShape. Does anyone maybe have a clue? :slight_smile:
Thanks for reading!

The CollisionShape’s position may be problematic, if the RigidBody’s position is far away from the child collision shape it’s center of mass will usually be around the RigidBody’s position, making a very strange pivot. Try setting the current_emotion’s position instead, and keep the current_frame.position at zero; avoid using reparent(..., true) if you can.

1 Like

thank so much @gertkeno ! In the end I found out that the problem was that the RigidBody scaled itself to 2.8 when i added it as a child to a node that scaled it down to 0.35x (which equals to 1 in the end). Once I rescaled to children of RigidBody2D and made some other adjustments to their sizes and positions, everything works in the RootScene! :sunny: