Skip to main content

Function: createLinearSpringEcsSystem()

createLinearSpringEcsSystem(time): EcsSystem<[LinearSpringEcsComponent], void>

Defined in: physics/systems/linear-spring.system.ts:24

Creates an ECS system that applies each matched entity's LinearSpringEcsComponent restoring force to bodyA/bodyB every tick: F = -k * x, where x is the signed difference between the current distance separating the two anchors and restLength, acting along the line between them. The force is scaled by deltaTimeInSeconds and applied via RigidBody.applyImpulse (the same continuous-force-via- scaled-impulse pattern used for gravity and wind, see the Applying Forces guide).

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

Parameters

time

Time

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

Returns

EcsSystem<[LinearSpringEcsComponent], void>