I know there is a activate() method an a RigidBody component that forces physics simulation for given body. I wonder if there is an opposing method, something like sleep() that marks body as non-movable/frozen and pauses simulation immediately?
My case: building a tower of boxes that should be immovable… In the best case, I would like to freeze/sleep all the boxes immediately after creation, so they stay ‘frozen’ until any of them gets some force applied to it.
I’m not sure about that. Definitely setting both linear/angular velocities to zero will lead eventually the body to rest (if there are no outside forces/collisions). But that won’t happen at the same frame.
I’ve tried different workarounds, these ones seem working:
this.entity.rigidbody.body.setActivationState(pc.RIGIDBODY_ISLAND_SLEEPING);
or this.entity.rigidbody.body.setActivationState(pc.RIGIDBODY_WANTS_DEACTIVATION);
Hey there! Yes, so it really depends on your logic. So, you could go with setting an activation flag to mark it as sleeping. That’s what the physics engine will do to it automatically when it rests. However, it would also mean that other object can wake it up, if one would touch it. It won’t be affected by gravity, but other forces may wake it at the end of the current simulation step.
The easiest option is to set linear and angular factors to zero when you want to freeze it in place, and then back to 1 on all axii, when you want to unfreeze it.