CharacterBody2D
Inherits: PhysicsBody2D < CollisionObject2D < Node2D < CanvasItem < Node < ObjectDescription
A 2D physics body specialized for characters moved by script. They are not affected by physics but affect other physics bodies in their path.Properties
Vector2
default:"Vector2(0, 0)"
Current velocity vector in pixels 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.
Vector2
default:"Vector2(0, -1)"
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 by default).
float
default:"1.0"
Sets a snapping distance. When set to a value different from 0.0, the body is kept attached to slopes.
Methods
move_and_slide
is_on_floor
is_on_wall
is_on_ceiling
get_floor_normal
Example Usage
- GDScript
- C#