Stop a rigidbody from rotating/moving/jittering anymore once it slows down

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sir_Skurpsalot

I’m trying to get some rigidbodies to calm down and stop moving /jittering so much once they hit the ground. I am using them for things like grenades, spent brass, empty magazines. All I really need is for them to behave like the grenades in good old quake, where once their linear velocity is 0, they freeze and do not move or rotate at all anymore. In quake there was two simple lines of code that caused the angular velocity to be set to 0 0 0 if the linear velocity is 0 0 0, but writing the equivalent in Godot does not seem to work. I feel the answer may lie in using _integrate_forces and changing properties of the PhysicsBodyDirectState but I do not understand how to access a PhysicsBodyDirectState. Any ideas?

:bust_in_silhouette: Reply From: jgodfrey

A RigidBody has a booleansleeping property. Setting that to true should put the body to sleep until it’s woken up again by a collision or the apply_impulse method.

So, once you’re RB has reached a point where you want it to “stop”, just set its sleeping property.

Additionally, there are a number of other methods and properties on the RigidBody object that allow you to interrogate / interact with its sleeping state.

That works! Thanks jgodfrey

Sir_Skurpsalot | 2020-01-25 19:26