3D rigidbody movement around a sphere in Godot4

In the code that you’ve provided, I don’t see any torque being added to the physics body. I assume that you’ve deleted your previous attempts at rotating the body in the manner that you’re describing.

There is a variety of ways that you can manipulate a RigidBody3D. One is obviously forces, but you can also manipulate its state directly via _integrate_forces() and the supplied state-parameter.

Questions

  • Have you tried setting the state.transform to a transform with your desired rotation?
  • What have you tried before (that ended up not working)?
  • What is your end-goal with this character controller (see sidenote)?
  • How does using a RigidBody3D, over a CharacterBody3D, make gravity easier to implement?

Please answer these questions. It would help us get a better idea of what your exact problem is.

SIDENOTE
I do, somewhat, agree with @dragonforge-dev. The CharacterBody3D class is specifically designed for the typical use case of a moving character. For your specific use case, you can use CharacterBody3D.up_direction to ensure that it interprets the world in a manner that is correct for your project (e.g. setting up_direction to -down_vector).

That said, it is entirely possible to achieve a similar result with a RigidBody3D if you know what you’re doing. Just know that it requires more work. Unless you have a unique system in mind, you are, in fact…

2 Likes