Skip to content

API Class CharacterController

github-actions[bot] edited this page Nov 24, 2026 · 4 revisions

Class: CharacterController

Defined in: src/plugins/physics/runtime/CharacterController.ts:41

A character that moves by move(motion) and slides along what it hits instead of being pushed by forces (ADR 0005, 0091), on Rapier's kinematic character controller. Its shape is an upright capsule (radius, height with the caps included, at center) that doesn't turn with the node. It climbs slopes up to slopeLimit and steps up to stepOffset high, keeps to the ground over small drops (snapToGround), and with pushBodies pushes dynamic bodies it walks into as if it weighed mass. It never needs a RigidBody, and ignores one on its node or above it.

Gravity is yours to apply: add it to the motion you pass to move, or use simpleMove.

Extends

Constructors

Constructor

new CharacterController(): CharacterController;

Returns

CharacterController

Inherited from

Collider.constructor

Properties

center

center: Vector3;

Defined in: src/plugins/physics/runtime/Collider.ts:19

Offset from the node's origin, in local units.

Inherited from

Collider.center


height

height: number = 2;

Defined in: src/plugins/physics/runtime/CharacterController.ts:43


isTrigger

isTrigger: boolean = false;

Defined in: src/plugins/physics/runtime/Collider.ts:21

Triggers report overlaps (onTriggerEnter/Exit) but don't collide.

Inherited from

Collider.isTrigger


layer

layer: string = "Default";

Defined in: src/plugins/physics/runtime/Collider.ts:23

Collision layer name from project settings.

Inherited from

Collider.layer


mass

mass: number = 1;

Defined in: src/plugins/physics/runtime/CharacterController.ts:55

How heavy it is when pushing bodies.


material

material: PhysicsMaterial;

Defined in: src/plugins/physics/runtime/Collider.ts:24

Inherited from

Collider.material


moveWithPlatforms

moveWithPlatforms: boolean = true;

Defined in: src/plugins/physics/runtime/CharacterController.ts:57

Ride kinematic and dynamic bodies it stands on (moving platforms), moving with them each fixed step.


pushBodies

pushBodies: boolean = true;

Defined in: src/plugins/physics/runtime/CharacterController.ts:53

Push dynamic bodies it runs into.


radius

radius: number = 0.5;

Defined in: src/plugins/physics/runtime/CharacterController.ts:42


skinWidth

skinWidth: number = 0.02;

Defined in: src/plugins/physics/runtime/CharacterController.ts:49

Gap kept between the capsule and what it touches, in units. Small but not zero.


slopeLimit

slopeLimit: number = 45;

Defined in: src/plugins/physics/runtime/CharacterController.ts:45

The steepest slope it walks up, in degrees; steeper ones are walls.


snapToGround

snapToGround: number = 0.2;

Defined in: src/plugins/physics/runtime/CharacterController.ts:51

How far down it sticks to the ground when walking off small drops or down slopes, in units (0: never).


stepOffset

stepOffset: number = 0.3;

Defined in: src/plugins/physics/runtime/CharacterController.ts:47

The highest step it climbs without jumping, in units (0: none).

Accessors

attachedRigidbody

Get Signature

get attachedRigidbody(): RigidBody | null;

Defined in: src/plugins/physics/runtime/CharacterController.ts:79

Never attached to a body: a character controller moves itself.

Returns

RigidBody | null

Overrides

Collider.attachedRigidbody


collisionFlags

Get Signature

get collisionFlags(): CollisionFlags;

Defined in: src/plugins/physics/runtime/CharacterController.ts:69

Which sides touched something during the last move.

Returns

CollisionFlags


enabled

Get Signature

get enabled(): boolean;

Defined in: src/engine/core/Component.ts:57

Returns

boolean

Set Signature

set enabled(value): void;

Defined in: src/engine/core/Component.ts:61

Parameters
value

boolean

Returns

void

Inherited from

Collider.enabled


gameObject

Get Signature

get gameObject(): GameObject;

Defined in: src/engine/core/Component.ts:37

Unity-style alias for node.

Returns

GameObject

Inherited from

Collider.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

Defined in: src/engine/core/Component.ts:68

True when enabled, the node is active in the hierarchy, and the node is in a loaded world.

Returns

boolean

Inherited from

Collider.isActiveAndEnabled


isGrounded

Get Signature

get isGrounded(): boolean;

Defined in: src/plugins/physics/runtime/CharacterController.ts:64

True if the last move ended on the ground (or snapped to it).

Returns

boolean


node

Get Signature

get node(): GameObject;

Defined in: src/engine/core/Component.ts:32

The node this component is on.

Returns

GameObject

Inherited from

Collider.node


owner

Get Signature

get owner(): GameObject;

Defined in: src/engine/core/Component.ts:45

The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).

Returns

GameObject

Inherited from

Collider.owner


time

Get Signature

get time(): Readonly<TimeState>;

Defined in: src/engine/core/Component.ts:93

This component's World's clock (ADR 0032): the same values as Time, but safe to read outside the World's frame too (after an await, say).

Returns

Readonly<TimeState>

Inherited from

Collider.time


transform

Get Signature

get transform(): Transform;

Defined in: src/engine/core/Component.ts:51

The Transform of the node this component is on, if it has one.

Returns

Transform

Inherited from

Collider.transform


velocity

Get Signature

get velocity(): Vector3;

Defined in: src/plugins/physics/runtime/CharacterController.ts:74

The velocity of the last move: how far it actually went, over the frame's deltaTime. Returns a copy.

Returns

Vector3


world

Get Signature

get world(): WorldHandle;

Defined in: src/engine/core/Component.ts:82

A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json"). Throws for a World no Engine owns.

Returns

WorldHandle

Inherited from

Collider.world

Methods

instantiate()

instantiate(prefabPath, options?): GameObject;

Defined in: src/engine/core/Component.ts:103

Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate. Use it in code that may run after an await: by then the frame is over and the current World is the Engine's default one, which may not be this component's. A parent from another World throws.

Parameters

prefabPath

string

options?

InstantiateOptions = {}

Returns

GameObject

Inherited from

Collider.instantiate


move()

move(motion): CollisionFlags;

Defined in: src/plugins/physics/runtime/CharacterController.ts:89

Move by motion (world units), sliding along walls, climbing slopes and steps, and stopping at obstacles. The node moves at once. Returns which sides it touched; onControllerColliderHit runs on the node's behaviors for each collider it hit. Before 3D physics has created the controller (its first fixed step), the node moves unobstructed.

Parameters

motion

Vec3Like

Returns

CollisionFlags


simpleMove()

simpleMove(speed): boolean;

Defined in: src/plugins/physics/runtime/CharacterController.ts:109

Walk at speed (units per second, its vertical part ignored) for this frame, falling with the World's gravity when not grounded. Returns isGrounded.

Parameters

speed

Vec3Like

Returns

boolean

Clone this wiki locally