Put an object back on track

see this video for reference
How do I detect when an object (Let’s say Sinbad) has come to rest after falling so I can put it back on track?
I would like to raise it up on feet, kind of reset the model so the game can continue.

Thank you

1 Like

Physics controls have a velocity. If that velocity is zero then it isn’t moving.


Note that rigid bodies have both linear and angular velocities. Also, the floating-point comparisons should be approximate.

Another approach would be to test isActive(), which becomes true after both velocities fall below certain thresholds for a certain period of time.

1 Like

Is the method backwards or is there a typo in your comment? I’d expect “active” to be false when the object was no longer active.

1 Like

Right. It becomes false after both velocities fall below threshold.

Excellent! I’m using isActivate() and it’s working as expected.
Now I want to put the object (Sinbad) back on his feet. Kind of reset the RigidBodyControl to 0,0,0 but do it gradually.
I have this function:
public void physicalRotateModel(RigidBodyControl ctl, int axisNum, float direction, float rotateVal) {

    float x=0,y=0,z=0;
    if(axisNum==1) {
        x=rotateVal * direction * FastMath.DEG_TO_RAD;
    } else if(axisNum==2) {
        y=rotateVal * direction * FastMath.DEG_TO_RAD;
    } else if(axisNum==3) {
        z=rotateVal * direction * FastMath.DEG_TO_RAD;

    Quaternion rot = ctl.getPhysicsRotation().fromAngles(x,y,z);

But what happens is that when I just start rotating the RigidBodyControl it fully resets itself to 0,0,0 so the comeback on his feet is not made gradually.
Any ideas why does it happen and how can I reset the RigidBodyControl rotation gradually ?

Thank you :slight_smile:

To interpolate between 2 quaternions, you might use Quaterion.nlerp(q2, blend).