Rigid body ignore outside forces

Godot Version

4.3

Question

Hello! I have a rigid body (Astronaut) as a child of another rigid body (Spaceship).
The goal is to be able change the ship rotation, position and velocity without the Astronaut being affected.

I tried it with this code:

func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
	state.linear_velocity = ship.linear_velocity

But the astronaut still moves when I use apply_force in the _physics_process of the ship.

I also thought about fixing the relative position of the astronaut in _integrate_forces, but that disables me to move the astronaut around in the ship with physics working.

If someone has an idea or sees a mistake, I would really appreciate it :smiley:

You shouldn’t attach a rigidbody as a child of another rigidbody - that messes up with the physics of the child rigidbody.
Can you maybe just apply the force to both rigidbodies at the same time? I feel like this should work.

1 Like

Thanks your help!

That isn’t really enough because if the outer Body collides with something I don’t know how to propagate this information to the inner body, correctly.

Also if it is not a child this means I need to handle the position changes do to the rotation of the ship manually which is bad because setting the position values in _integrate_forces seems to interfere with the Physics engine (and adding impulses / forces to move something to a specific location doesn’t seem to be intended).

Can you share a short video of how your game looks like and how it behaves in terms of physics, so that I can better understand what’s your ultimate goal?

Maybe rigidbody is not the correct choice here, because as you mentioned already - synchronizing physics between 2 objects may be tricky.

Thanks, sharing the video is a great Idea!


(In the video I add forces to the ship and the character movement results from the changed ship velocity, and collision with the ship wall).

So the goal is that my character is standing on the ground of the ship but doesn’t move except when the player moves it. But the rotation and velocity changes of the ship shouldn’t affect it.

Have you tried using CharacterBody3D instead of RigidBody3D for your player node (the inner body)? This way you can attach it as a child to your ship and all position and rotation of the ship will be translated to the player as well.

Yes thanks, but it has the big problem that if the character moves against the wall it will change the ships force the chip to change, because it doesn’t get affected by RigidBodys but RigidBodys get affected by it.

Yea, it really is a bit complicated to get it done and I’m not experienced with Godot physics :sweat_smile: