Skip to main content

Function: createPhysicsSyncEcsSystem()

createPhysicsSyncEcsSystem(physicsWorld, time): EcsSystem<[PhysicsBodyEcsComponent, PositionEcsComponent, RotationEcsComponent], void>

Defined in: physics/systems/physics-sync.system.ts:28

Creates an ECS system that steps physicsWorld and keeps it synchronized with the ECS world: registers/removes each entity's RigidBody as its PhysicsBodyEcsComponent comes and goes, and syncs its transform with the entity's PositionEcsComponent/RotationEcsComponent every tick (see PhysicsBodyEcsComponent.isKinematic for which side drives which). This system alone doesn't add any physics behavior beyond that sync - joints, torque, and motors are all separate systems layered on top (see the Applying Forces and Joints guides).

Parameters

physicsWorld

PhysicsWorld

The physics world to step and synchronize with the ECS.

time

Time

The time instance used to determine the simulation step size.

Returns

EcsSystem<[PhysicsBodyEcsComponent, PositionEcsComponent, RotationEcsComponent], void>