Skip to main content

CharacterBody3D

Inherits: PhysicsBody3D < CollisionObject3D < Node3D < Node < Object

Description

A 3D physics body specialized for characters moved by script. They are mainly used to provide high-level API to move objects with wall and slope detection.

Properties

Vector3
default:"Vector3(0, 0, 0)"
Current velocity vector (typically meters per second), used and modified during calls to move_and_slide.
MotionMode
default:"MOTION_MODE_GROUNDED"
Sets the motion mode which defines the behavior of move_and_slide.
Vector3
default:"Vector3(0, 1, 0)"
Vector pointing upwards, used to determine what is a wall and what is a floor.
float
default:"0.785398"
Maximum angle (in radians) where a slope is still considered a floor (45 degrees).
float
default:"0.1"
Sets a snapping distance. When set to a value different from 0.0, the body is kept attached to slopes.

Methods

move_and_slide

Moves the body based on velocity. Returns true if the body collided.

is_on_floor

Returns true if the body collided with the floor.

is_on_wall

Returns true if the body collided with a wall.

is_on_ceiling

Returns true if the body collided with the ceiling.

get_floor_normal

Returns the collision normal of the floor at the last collision point.

Example Usage