Skip to content

BodyComp

Defined in: packages/threeplay/src/plugins/physics/types.ts:99

Fields added by body(). Requires area(). It is a MoveHandler: move() sets the horizontal velocity of dynamic bodies and translates kinematic ones (static bodies ignore it, with a warning).

Dynamic bodies are interpolated: from update on, pos/rot hold the visual pose of the frame, up to one fixed step (20 ms) behind the simulation. fixedUpdate and collision callbacks see the latest simulated pose, and raycast, vel and isGrounded() always use the simulation. Assigning pos or rot from code teleports the body. Opt out with body({ interpolate: false }).

optional add(this): void

Defined in: packages/threeplay/src/core/types.ts:63

Called when the object enters the scene (or when used on a live object).

GameObj

void

Comp.add


applyForce(force): void

Defined in: packages/threeplay/src/plugins/physics/types.ts:106

Vec3Like

void


applyImpulse(impulse): void

Defined in: packages/threeplay/src/plugins/physics/types.ts:105

Vec3Like

void


applyMove(delta, velocity): void

Defined in: packages/threeplay/src/plugins/transform/types.ts:36

delta is the displacement for this frame, velocity the requested units/s.

Vector3

Vector3

void

MoveHandler.applyMove


applyTorqueImpulse(torque): void

Defined in: packages/threeplay/src/plugins/physics/types.ts:107

Vec3Like

void


optional destroy(this): void

Defined in: packages/threeplay/src/core/types.ts:69

Called when the object is destroyed or the component removed.

GameObj

void

Comp.destroy


optional fixedUpdate(this): void

Defined in: packages/threeplay/src/core/types.ts:67

Called at the fixed physics rate (50 Hz by default).

GameObj

void

Comp.fixedUpdate


optional inspect(this): string | null | undefined

Defined in: packages/threeplay/src/core/types.ts:71

Short status line shown by the debug inspector.

GameObj

string | null | undefined

Comp.inspect


isFalling(): boolean

Defined in: packages/threeplay/src/plugins/physics/types.ts:112

boolean


isGrounded(): boolean

Defined in: packages/threeplay/src/plugins/physics/types.ts:111

true if standing on something (ground probe below the collider).

boolean


jump(force?): void

Defined in: packages/threeplay/src/plugins/physics/types.ts:109

Sets the vertical velocity (default 8).

number

void


onGround(fn): EventController

Defined in: packages/threeplay/src/plugins/physics/types.ts:114

When the body lands.

() => void

EventController


teleport(to): void

Defined in: packages/threeplay/src/plugins/physics/types.ts:116

Teleports, resetting velocity.

Vec3Like

void


optional update(this): void

Defined in: packages/threeplay/src/core/types.ts:65

Called once per frame.

GameObj

void

Comp.update

angularVel: Vector3

Defined in: packages/threeplay/src/plugins/physics/types.ts:104

Angular velocity in degrees/s.


optional conflicts?: string[]

Defined in: packages/threeplay/src/core/types.ts:61

Ids of components that can’t be on the same object (checked both ways).

Comp.conflicts


id: "body"

Defined in: packages/threeplay/src/plugins/physics/types.ts:100

Unique name. Two components with the same id replace each other.

Comp.id


optional require?: string[]

Defined in: packages/threeplay/src/core/types.ts:59

Ids of components that must be present on the object.

Comp.require


vel: Vector3

Defined in: packages/threeplay/src/plugins/physics/types.ts:102

Linear velocity in units/s (read or assign).