Velocity2D

View source

ExtendsVector2

Stores an entity’s linear velocity in 2D as an ECS component.

Its x and y values describe movement along the two axes in coordinate units per second. A new component starts at (0, 0). Pair it with Position2D for an entity’s 2D position and Acceleration2D for a change in velocity.

Examples

import { Velocity2D } from '@wimaengine/movable'
import { Query, World } from '@wimaengine/ecs'

const world = new World()
world.spawn([new Velocity2D(2, -1)])

new Query(world, [Velocity2D]).each(([velocity]) => {
  velocity.x = 3
  velocity.y = 0
})

Constructor


Methods


staticserialize(value: Velocity2D): Vector2Like

View source

Parameters

NameDescriptionDefault
value——
  • @inheritDoc