Resetting Mesh to original position after physics are applied (with Havok)

Hi - i used to reset objects to their starting points by keeping track of the initial position - and then removing the imposters and resetting the mesh to that position. But that technique is not working any more with havok. Seems like i’ll need to un-bind the mesh from the body somehow?

Here’s a PG - what should the ResetBoxes() function do?

When i try to dispose of the body, i get:
Syncing transform failed for node custom: Cannot read properties of null (reading ‘hpBodyId’)…

Now you need to set

mesh.physicsBody.disablePreStep = false

before you can set the position of the physics body

Thanks that’s useful. I’m looking more for a way to reset by removing the body/shape from the mesh. I was thinking i could just dispose of it.

mesh.physicsBody.dispose();

That does actually work to reset, but it also throws a ton of unending info-warnings and also leaves the shape un-disposed:

Syncing transform failed for node custom: Cannot read properties of null (reading 'hpBodyId')

You have to remove the body from the viewer also: PhysicsV2 Add Bodies - reset | Babylon.js Playground (babylonjs.com)

1 Like

Aha!
Thx so much.