Client Physics Hooks
Client physics hooks let you extend client-side physics (including client prediction) fromsceneMap.
Use these hooks to keep collision rules aligned with the server.
Usage
Available Hooks
onPhysicsInit(scene, context)
Called when map physics is initialized.
scene: currentRpgClientMapcontext.mapData: map data used byloadPhysic()
onPhysicsEntityAdd(scene, context)
Called when a dynamic physics body is created.
context.owner: player/event owning the bodycontext.entity: physics entity instancecontext.kind:"hero" | "npc" | "generic"
entity.canEnterTile(...).
onPhysicsEntityRemove(scene, context)
Called before a dynamic physics body is removed.
Use this to unregister handlers created in onPhysicsEntityAdd.
onPhysicsReset(scene)
Called when the physics world is reset before reloading map physics.
Use this to clear global state and remaining subscriptions.
Best Practices
- Keep handlers deterministic and synchronous when possible.
- Use the same shared rule functions on client and server.
- Prefer hook-based setup over
setTimeout()for physics extensions.