rapier icon indicating copy to clipboard operation
rapier copied to clipboard

Stop a rigid body

Open APerricone opened this issue 3 years ago • 2 comments

Hi, In my project I would like reuse some rigid body, so stop them, move and sleep, I tried with:

reset(world :World) {
    let collider = world.getCollider(this.colliderId);
    let rigidBody = collider.parent()!;
    rigidBody.setTranslation(new Vector2(0,settings.ballHeight), false);
    rigidBody.setNextKinematicTranslation(new Vector2(0,settings.ballHeight));
    rigidBody.setRotation(0, false);
    rigidBody.setNextKinematicRotation(0);
    rigidBody.resetForces(false);
    rigidBody.resetTorques(false);
    rigidBody.sleep();
}

But it is still awake. It is TypeScript but I think the same issue is present with javascript and rust. I am using the 0.11.1

APerricone avatar Jan 29 '23 05:01 APerricone

it is strange, If I call only sleep the rigid body stops, but If I try to move it it wake up without possibility of keep it asleep

APerricone avatar Feb 01 '23 10:02 APerricone

I'm having the same issue. I'm not able to find a way of repositioning a rigid body and setting it to sleep on the same frame.

The work around I've been doing is moving the rigid body off screen and then calling .sleep() on it in a setTimeout. I still find I have to make sure the sleeping objects don't get moved into the same position off screen because then they wake each other up again.

I'm using 0.11.2

Would love a solution for this.

LukeCarlThompson avatar Jun 17 '23 11:06 LukeCarlThompson