# [SOLVED] Bullet RigidBodyControl wait until movement is done

Hello, I wonder what is best solution for this.

I have a RigidBodyControl on a person model and I want to make command move from x1=(0,0,0) to x2=(1,0,0) position. I can applyImpulse() to so that the model is moving to the position. But how can I know that the model is done moving to the position?

Is there a listener that says that the body is not moving anymore?

Or do I need to check the physical position of the body and if position=x2 then done?

1 Like

There is a `getLinearVelocity` method for finding the current velocity of the object and `getAngularVelocity` method for finding the amount of current rotation. These are both available on the `RigidBodyControl`.

`getLinearVelocity` if I recall returns a direction multiplied by a distance per physics tick in world units. `getAngularVelocity` returns how much the object is rotating in radians per physics tick.

Iâ€™m sure the javadoc will be of help.

Thereâ€™s no listener specifically for positions. Test the position after each physics tick, using a `PhysicsTickListener`. And donâ€™t use `==` on vectors or floats!

Did you ever arrive at a satisfactory solution?

Yes, thank you. I keep track of the object physical location and linear velocity now. Then I can react if the conditions are met.

Iâ€™m also use a PhysicsTickListener to move objects, because apply impulse will rotate my model.

``````@Data
private class MoveObjectInPhysicsSpace implements PhysicsTickListener {

boolean movementDone = false;

final RigidBodyControl control;

final Vector3f target;

final Vector3f position = new Vector3f();

final Vector3f velocity = new Vector3f(1f, 0f, 0f);

@Override
public void prePhysicsTick(PhysicsSpace space, float tpf) {
if (position.distanceSquared(target) < 0.1f) {
movementDone = true;
control.setLinearVelocity(Vector3f.ZERO);
physicsSpace.removeTickListener(this);
}
}

@Override
public void physicsTick(PhysicsSpace space, float tpf) {
if (movementDone) {
return;
}
control.setLinearVelocity(velocity);
control.getPhysicsLocation(position);
}

}``````
1 Like

what about RigidBodyControl.isActive() ? maybe you can use that to check when the movement is doneâ€¦

I believe thatâ€™s triggered when a rigidbody has been idle for a certain period, not immediately.

2 Likes

Also pretty sure that something can be â€śactiveâ€ť and not moving if some other object is on it, touching it, etcâ€¦