Skip to content

Commit

Permalink
Set prestep when physics changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tracygardner committed Jul 26, 2024
1 parent 3eb72f9 commit 8cb4707
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flock.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ export async function setPhysics(modelName, physicsType) {
mesh.physics._pluginData.hpBodyId,
mesh.physics.startAsleep,
);
mesh.physics.disablePreStep = true;
break;
case "DYNAMIC":
mesh.physics.setMotionType(BABYLON.PhysicsMotionType.DYNAMIC);
Expand All @@ -976,6 +977,7 @@ export async function setPhysics(modelName, physicsType) {
mesh.physics._pluginData.hpBodyId,
mesh.physics.startAsleep,
);
mesh.physics.disablePreStep = false;
break;
case "ANIMATED":
mesh.physics.setMotionType(BABYLON.PhysicsMotionType.ANIMATED);
Expand All @@ -984,13 +986,15 @@ export async function setPhysics(modelName, physicsType) {
mesh.physics._pluginData.hpBodyId,
mesh.physics.startAsleep,
);
mesh.physics.disablePreStep = false;
break;
case "NONE":
mesh.physics.setMotionType(BABYLON.PhysicsMotionType.STATIC);
window.hk._hknp.HP_World_RemoveBody(
hk.world,
mesh.physics._pluginData.hpBodyId,
);
mesh.physics.disablePreStep = true;
break;
default:
console.error("Invalid physics type provided:", physicsType);
Expand Down

0 comments on commit 8cb4707

Please sign in to comment.