Interface

BodyComp

:

The body component.

group Component Types

vel

: Vec2

Object current velocity.

since v3001.0

damping

: number

How much velocity decays (velocity *= 1 / (1 + damping * dt) every frame).

since v3001.0

isStatic

: boolean

If object is static, it won't move, all non static objects won't move past it, and all calls to addForce(), applyImpulse(), or jump() on this body will do absolutely nothing.

jumpForce

: number

Initial speed in pixels per second for jump().

gravityScale

: number

Gravity multiplier.

mass

: number

Mass of the body, decides how much a non-static body should move when resolves with another non-static body. (default 1).

since v3000.0

stickToPlatform

?: boolean

If object should move with moving platform (default true).

since v3000.0

curPlatform

(): GameObj | null

Current platform landing on.

isGrounded

(): boolean

If currently landing on a platform.

since v2000.1

isFalling

(): boolean

If currently falling.

since v2000.1

isJumping

(): boolean

If currently rising.

since v3000.0

applyImpulse

(impulse: Vec2): void

Applies an impulse

param impulse- The impulse vector, applied directly

addForce

(force: Vec2): void

Applies a force

param force- The force vector, applied after scaled by the inverse mass

jump

(force?: number): void

Upward thrust.

onPhysicsResolve

(action: (col: Collision) => void): KEventController

Register an event that runs when a collision is resolved.

since v3000.0

onBeforePhysicsResolve

(action: (col: Collision) => void): KEventController

Register an event that runs before a collision would be resolved.

since v3000.0

onGround

(action: () => void): KEventController

Register an event that runs when the object is grounded.

since v2000.1

onFall

(action: () => void): KEventController

Register an event that runs when the object starts falling.

since v2000.1

onFallOff

(action: () => void): KEventController

Register an event that runs when the object falls off platform.

since v3000.0

onHeadbutt

(action: () => void): KEventController

Register an event that runs when the object bumps into something on the head.

since v2000.1

onLand

(action: (obj: GameObj) => void): KEventController

Register an event that runs when an object lands on this object.

since v3001.0

onHeadbutted

(action: (obj: GameObj) => void): KEventController

Register an event that runs when the object is bumped by another object head.

kaplay logo

Layer

Miscalenous