createRawMovable2D

View sourcecreateRawMovable2D(x?: number, y?: number, a?: number): [Velocity2D, Rotation2D, Acceleration2D, Torque2D]

Creates an ordered 2D motion-only component bundle.

The returned tuple contains Velocity2D, Rotation2D, Acceleration2D, and Torque2D in insertion order. The supplied x and y values initialize velocity, a initializes angular motion in radians, and acceleration and torque start at zero. Use createMovable2D when the entity also needs the standard 2D transform components.

Examples

import { World } from '@wimaengine/ecs'
import { createRawMovable2D } from '@wimaengine/movable'

const world = new World()
world.spawn(createRawMovable2D(2, 0, 0.1))

Parameters

NameDescriptionDefault
x?

Initial x velocity.

0
y?

Initial y velocity.

0
a?

Initial angular motion in radians.

0

Returns

Ordered motion components.