From 8cb470796185aa8efe225bd52c623053d5740542 Mon Sep 17 00:00:00 2001 From: Dr Tracy Gardner Date: Fri, 26 Jul 2024 11:13:21 +0000 Subject: [PATCH] Set prestep when physics changes --- flock.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flock.js b/flock.js index be85778..d362095 100644 --- a/flock.js +++ b/flock.js @@ -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); @@ -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); @@ -984,6 +986,7 @@ 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); @@ -991,6 +994,7 @@ export async function setPhysics(modelName, physicsType) { hk.world, mesh.physics._pluginData.hpBodyId, ); + mesh.physics.disablePreStep = true; break; default: console.error("Invalid physics type provided:", physicsType);