Skip to content

API Class CharacterController2D

github-actions[bot] edited this page Nov 28, 2026 · 6 revisions

Class: CharacterController2D

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:32

The 2D CharacterController (ADR 0091): an upright capsule (radius, height with the caps included) that moves by move(motion), sliding along what it hits, climbing slopes up to slopeLimit and steps up to stepOffset, sticking to the ground over small drops (snapToGround) and, with pushBodies, pushing dynamic bodies. "Up" is +y. Gravity is yours to apply, or use simpleMove.

Extends

Constructors

Constructor

new CharacterController2D(): CharacterController2D;

Returns

CharacterController2D

Inherited from

Collider2D.constructor

Properties

center

center: Vector2;

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

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

Inherited from

Collider2D.center


height

height: number = 2;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:34


isTrigger

isTrigger: boolean = false;

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

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

Inherited from

Collider2D.isTrigger


layer

layer: string = "Default";

Defined in: src/plugins/physics/runtime/Collider2D.ts:25

Collision layer name from project settings.

Inherited from

Collider2D.layer


mass

mass: number = 1;

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

How heavy it is when pushing bodies.


material

material: PhysicsMaterial;

Defined in: src/plugins/physics/runtime/Collider2D.ts:26

Inherited from

Collider2D.material


moveWithPlatforms

moveWithPlatforms: boolean = true;

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

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


oneWay

oneWay: boolean = false;

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

A character controller is never a one-way platform itself; it honours other colliders' oneWay (ADR 0439).

Overrides

Collider2D.oneWay


pushBodies

pushBodies: boolean = true;

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


radius

radius: number = 0.5;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:33


skinWidth

skinWidth: number = 0.02;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:40

Gap kept between the capsule and what it touches, in units.


slopeLimit

slopeLimit: number = 45;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:36

The steepest slope it walks up, in degrees.


snapToGround

snapToGround: number = 0.2;

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

How far down it sticks to the ground, in units (0: never).


stepOffset

stepOffset: number = 0.3;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:38

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

Accessors

attachedRigidbody

Get Signature

get attachedRigidbody(): RigidBody2D | null;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:70

The body this collider is attached to: the nearest active RigidBody2D on this node or an ancestor.

Returns

RigidBody2D | null

Overrides

Collider2D.attachedRigidbody


collisionFlags

Get Signature

get collisionFlags(): CollisionFlags;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:61

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

Collider2D.enabled


gameObject

Get Signature

get gameObject(): GameObject;

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

Unity-style alias for node.

Returns

GameObject

Inherited from

Collider2D.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

Collider2D.isActiveAndEnabled


isGrounded

Get Signature

get isGrounded(): boolean;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:56

True if the last move ended on the ground.

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

Collider2D.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

Collider2D.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

Collider2D.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

Collider2D.transform


velocity

Get Signature

get velocity(): Vector2;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:66

The velocity of the last move (distance moved over the frame's deltaTime). Returns a copy.

Returns

Vector2


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

Collider2D.world

Methods

dropThrough()

dropThrough(): void;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:98

Pass down through every one-way collider it stands on or overlaps now (ADR 0439): Down + Jump on a plank. One-way colliders reached later still hold it, so the next platform below catches it; solid colliders always do. Does nothing on a backend without one-way platforms.

Returns

void


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

Collider2D.instantiate


move()

move(motion): CollisionFlags;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:75

Move by motion, sliding along what it hits. The node moves at once. See CharacterController.move.

Parameters

motion

Vec2Like

Returns

CollisionFlags


simpleMove()

simpleMove(speed): boolean;

Defined in: src/plugins/physics/runtime/CharacterController2D.ts:103

Walk at speed.x units per second for this frame, falling with gravity when not grounded. Returns isGrounded.

Parameters

speed

Vec2Like

Returns

boolean

Clone this wiki locally