diff --git a/example/8-Ball.ts b/example/8-Ball.ts index 276c20e8..a7555a67 100644 --- a/example/8-Ball.ts +++ b/example/8-Ball.ts @@ -222,6 +222,7 @@ class BilliardPhysics { const pocket = fA.getUserData() === POCKET ? bA : fB.getUserData() === POCKET ? bB : null; if (ball && pocket) { + // do not change world immediately this.world.queueUpdate(() => { this.world.destroyBody(ball); this.client?.onBallInPocket(ball, pocket); diff --git a/example/Asteroid.ts b/example/Asteroid.ts index 74f69624..880d2b0e 100644 --- a/example/Asteroid.ts +++ b/example/Asteroid.ts @@ -231,12 +231,14 @@ class AsteroidPhysics { const asteroid = dataA?.type == "asteroid" ? bodyA : dataB?.type == "asteroid" ? bodyB : null; if (ship && asteroid) { + // do not change world immediately this.world.queueUpdate(() => { this.client?.collideShipAsteroid(ship, asteroid); }); } if (bullet && asteroid) { + // do not change world immediately this.world.queueUpdate(() => { this.client?.collideBulletAsteroid(bullet, asteroid); });