Hi team,
Is there any method to temporarily disable a physics body/shape ?
I have some meshes imported at scene creation, they’re then prepared for cloning/instancing/thinInstancing, some light shaders are precompiled, physics bodies setup, etc, then they’re disabled mesh.setEnabled(false)
,
but the bodies are still there and enabled/active meshes can collide with them.
1 Like
You can call plugin._hknp.HP_World_RemoveBody(world, bodyID)
This removes the body from the physics world, but as long as you don’t call plugin._hknp.HP_Body_Release(bodyID), it is still allocated in the plugin and preserves information like transform and shape
To then add it again you simply call plugin._hknp.HP_World_AddBody(world, bodyID, startAsleep)
1 Like
Seems good so far
made a little prototype to help out
BABYLON.HavokPlugin.prototype.setPhysicsBodyEnabled = function(body, setEnabled = true){
if(!body || !body._pluginData) return;
if(setEnabled){
this._hknp.HP_World_AddBody(this.world, body._pluginData.hpBodyId, body.startAsleep);
}
else {
this._hknp.HP_World_RemoveBody(this.world, body._pluginData.hpBodyId);
}
};
3 Likes