Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(physics): parented-body set refreshes each fixed step

esengine26d52376ebe8
diff --git a/sdk/src/physics/PhysicsSystem.ts b/sdk/src/physics/PhysicsSystem.ts
index f4b7c5a55..e28ddad51 100644
--- a/sdk/src/physics/PhysicsSystem.ts
+++ b/sdk/src/physics/PhysicsSystem.ts
@@ -872,6 +872,15 @@ export function registerPhysicsSystem(
collectEvents(module, ppu, events);
capturePhysicsPoses(module, snaps);
+
+ // Membership decides batch-vs-parented writeback; a runtime
+ // reparent of a live body would otherwise stay on the batch path
+ // and get its world pose written as a local one. Refreshed per
+ // fixed step, so a reparent takes effect on the next physics tick.
+ for (const entity of trackedEntities) {
+ if (world.has(entity, Parent)) parentedBodies.add(entity);
+ else parentedBodies.delete(entity);
+ }
},
{ name: 'PhysicsStepSystem' }
),