RigidBody3D random teleporting

I’m noticing one thing in particular.

Not using _physics_process() and _integrate_forces()

The code that you’re using to add forces to your rigidbody is located within _process(). _process() runs at the same rate the game is rendered, but physics are only updated at a set rate. In other words, the update rate of the rendering and the physics are not the same. It is for this reason that most game engines have a seperate update function for physics, namely _physics_process().

_physics_process() runs at the same rate as physics are updated and so this is typically where you would add force, torque or impulses.

In addition, RigidBody3D/RigidBody2D has a separate processing function called _integrate_forces(). This function should be used whenever the goal is to directly modify the state of the rigidbody (e.g. its position, rotation, velocity etc.). Since you’re directly modifying the rotation of the object, you should be using _integrate_forces() as well.

In general, always use _physics_process() and _integrate_forces() when working with continuous physics interactions - otherwise…

Resources

P.S. Great formulation of your issue. It made it as easy as possible to debug.