Skip to main content

Function: createAngularVelocityMotorEcsSystem()

createAngularVelocityMotorEcsSystem(time): EcsSystem<[AngularVelocityMotorEcsComponent, PhysicsBodyEcsComponent], void>

Defined in: physics/systems/angular-velocity-motor.system.ts:26

Creates an ECS system that drives each matched entity's PhysicsBodyEcsComponent's RigidBody towards its AngularVelocityMotorEcsComponent.targetVelocity every tick, spending no more torque than maxTorque to do so. The torque needed to close the gap to targetVelocity in a single tick is computed from the body's inertia and the tick's delta time, then clamped to [-maxTorque, maxTorque] before being applied via RigidBody.applyTorque.

Must be registered with the EcsWorld before createPhysicsSyncEcsSystem (or with an earlier registrationOrder), so the motor's torque is reflected in the same tick's physicsWorld.step.

Parameters

time

Time

The time instance used to scale torque by the tick's delta time.

Returns

EcsSystem<[AngularVelocityMotorEcsComponent, PhysicsBodyEcsComponent], void>