dampenVelocity2D

View sourcedampenVelocity2D(world: World): void

Damps the linear velocity of every matching 2D entity.

Damping2DPlugin registers this exact function directly in the repeating AppSchedule.Update schedule. The registration does not specify a system group, so the schedule’s default group is used. The plugin also installs the required Linear2DDamping resource.

The query requires exactly Velocity2D. Before iterating, the system reads world.getResource(Linear2DDamping).value and calculates the multiplier 1 - value. It then scales each queried vector with Vector2.multiplyScalar using the same vector as the output, so every Velocity2D component is mutated in place. The resource must exist; a missing resource causes resource lookup to throw.

Examples

import { AppSchedule } from '@wimaengine/core'
import { dampenVelocity2D } from '@wimaengine/damping'

app.registerSystem({
  schedule: AppSchedule.Update,
  system: dampenVelocity2D
})
// Damping2DPlugin already installs this system and Linear2DDamping.

Parameters

NameDescriptionDefault
world

Update world containing Velocity2D and Linear2DDamping.

—