Skip to content

Search

Documentation

character2d

A 2D character controller: node.character2d.move_by slides the node along walls and steps it up ledges. Needs a collider2d; a kinematic body2d lets it…

On this page

2d · physics · 17 properties · 2D

A 2D character controller: node.character2d.move_by slides the node along walls and steps it up ledges. Needs a collider2d; a kinematic body2d lets it push bodies.

In a scene, character2d is the node key that applies it. A script reaches each property below as a field on node.character2d: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.character2d.get() and node.character2d.set(table).

Properties

property type default description
exclude list [] Nodes a move passes through: their colliders, and every collider on their body
exclude_kinds flags [] The body kinds a move passes through: static takes colliders with no body too. The character's own collision_layer and collision_mask filter the rest One of static, kinematic, dynamic.
floor_max_angle float 0.7853982 The steepest slope the character may walk up; radians in the file, degrees in the inspector Range 0–90.
floor_snap_length float 0.2 How far below its feet the character looks for ground to stay stuck to over a crest; 0 turns snapping off At least 0.
hit_sensors bool false Stop at sensors; off, a move passes through them
hit_solids bool true Stop at colliders that are not sensors; off, a move passes through them
lengths enum absolute Whether floor_snap_length, step_height, step_min_width and safe_margin are world units or fractions of the character's shape: relative measures the width across up_direction for step_min_width, and the height along it for the rest One of absolute, relative.
min_slide_angle float 0.5235988 The shallowest slope the character slides back down; radians in the file, degrees in the inspector Range 0–90.
normal_nudge float 0.0001 A tiny push along the contact normal that stops the character catching on seams At least 0.
push_bodies bool true Push dynamic bodies the character walks into, rather than passing through them
push_mass float 0 The mass a push is worked out with; 0 takes the body's mass, or the colliders' when there is no body At least 0.
safe_margin float 0.01 A gap kept between the character and everything else, so the solver never has to push it out of a wall At least 0.
slide bool true Slide along what is in the way instead of stopping dead against it
step_height float 0.3 The tallest step the character climbs without jumping; 0 turns stepping off At least 0.
step_min_width float 0.2 How much clear ground a step needs on top before it may be climbed At least 0.
step_on_dynamic bool false Climb onto dynamic bodies too, not only static and kinematic ones
up_direction vec2 [0,1] Which way is up for this character: the axis it stands along and measures slopes against

Script functions

Methods of node.character2d, the handle a node carrying this component exposes. Every handle also has get(), set(table), patch(table), has() and remove().

From physics2d:

method what it does
move_character_by(Vec2) -> physics2d::CharacterMove Move the character by an offset, sliding along walls, climbing steps and staying on the ground. Every solid collider of the character is swept. Call it from fixed_update.

Are you sure?