CharacterBody
API reference for CharacterBody. Access via the 'physics' submodule.
Experimental API:
The physics submodule is a VERY experimental and new API that is highly susceptible to breaking changes in the future.
Inherits from Body.
Constructor
-
CharacterBody(world: World) → CharacterBody
Properties
| Name | Description | Type |
|---|---|---|
floor_max_angle | Maximum angle (in radians) to consider a surface as a floor. Default is ~45 degrees. | float |
floor_snap_distance | Distance in pixels to probe downward for floor detection. Default is 5.0. | float |
mass | The mass of the character body. Default is 80.0. | float |
velocity | The velocity of the character body. | Vec2 |
Methods
Is On Ceiling
is_on_ceiling() → boolWhether the character is currently touching a ceiling.
Is On Floor
is_on_floor() → boolWhether the character is currently on a floor surface.
Is On Wall
is_on_wall() → boolWhether the character is currently touching a wall.
Move And Slide
move_and_slide(delta: SupportsFloat = -1.0) → NonePerform movement and collision resolution for the character.
This method moves the character according to the velocity property and resolves collisions by sliding along surfaces. It also updates the floor/ceiling/wall contact states.
Args
delta: The time step to use for movement. Defaults to -1.0, which uses the frame delta.