0 votes

Hey guys,

I'd like to dynamically add some simple Meshes (blocks) to a RigidBody. Tried several things and ended up with:
1) adding a Meshinstance
2) adding an appropriate CollisionShape

Looks good in the first place, collisions work and it looks correct, BUT it seems that all new elements do not have any weight. So gravity only works on the initial mesh.

Any hints?

Best
Thorsten

Godot version v3.3
in Engine by (15 points)

Physics/gravity acts on the body, not the meshes. It sounds like maybe you're not adding the meshes as children of the body? Show your code where you're doing this.

Hi there,

I just tried in the Editor (added meshes and collision shapes). Only the first shape/mesh added seems to have weight.

However - I'm missing add_shape (Godot 2) as method for RigidBody. How would I have to do it now?

You need to show what you're doing then. Because again, a mesh can't have weight. Only the rigid body has physics properties. Meshes should be attached to it to give it visible components.

http://polyaktiv.de/godot_rigid_body2.png
This is what I tried in the editor (Scene tree), and yes, MeshInstances and CollisionShapes do match :)

http://polyaktiv.de/godot_rigid_body.png
The RigidBody with all elements falls correctly and the collisions work, a but in the end everything behaves as if only the first box has weight. You can add as many boxes to the side, the body will never fall over. That's weird, isn't it?

Thanks for your support. Love your tutorials!

1 Answer

+1 vote
Best answer

I see. That's not weird at all because the rigid body acts as one body. Adding additional meshes and shapes does not change its behavior. You seem to be expecting that the body's center of mass will move when adding additional shape children, but this is not the case.

The RigidBody's center of mass is its position. You would need to distribute those collision shapes around the center as desired to change it. For example, here are three rigid bodies with multiple collision shapes. Notice how I've placed them relative to the body's position:

enter image description here

When they fall to the ground, they pivot around their center of mass:

enter image description here

by (20,897 points)
selected by

Thanks, that was very enlightening, a perfect illustration. And a little disappointing in terms of what I had in mind. (I wanted to dynamically add blocks (completely stiff) until the whole structure is out of balance.)

Thanks again!

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.