A kinematic physics body designed for player-controlled characters. Access via the 'physics' submodule.
Experimental API:
The physics submodule is an experimental and new API that is highly susceptible to breaking changes in the future.
Inherits from Body.
CharacterBody(world: World) → CharacterBodyCharacterBody(world: World) → CharacterBody
A kinematic physics body designed for player-controlled characters.
| Name | Description | Type |
|---|---|---|
motion_mode | The motion mode of the character. | CharacterBody.MotionMode |
velocity | The velocity of the character body. | Vec2 |
mass | The simulated mass of the character for pushing rigid bodies. | float |
max_speed | The maximum speed the character can move. | float |
acceleration | The acceleration applied when moving. | float |
friction | The friction applied when on the ground. | float |
stop_speed | The speed threshold below which the character will stop moving. | float |
air_steer | The control factor for steering while in the air (0.0 to 1.0). | float |
capsule_shape | The capsule shape used for ground detection and collision casting. | Capsule |
move_and_slide(delta: float = -1.0) → Nonemove_and_slide(delta: float = -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.is_on_floor() → boolis_on_floor() → boolCheck if the character is currently in contact with the floor.
Returns
bool : True if the character is on the floor, False otherwise.
is_on_ceiling() → boolis_on_ceiling() → boolCheck if the character is currently in contact with the ceiling.
Returns
bool : True if the character is on the ceiling, False otherwise.
is_on_wall() → boolis_on_wall() → boolCheck if the character is currently in contact with a wall.
Returns
bool : True if the character is on a wall, False otherwise.