123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548 |
- :github_url: hide
- .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
- .. DO NOT EDIT THIS FILE, but the CharacterBody3D.xml source instead.
- .. The source is found in doc/classes or modules/<name>/doc_classes.
- .. _class_CharacterBody3D:
- CharacterBody3D
- ===============
- **Inherits:** :ref:`PhysicsBody3D<class_PhysicsBody3D>` **<** :ref:`CollisionObject3D<class_CollisionObject3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
- Specialized 3D physics body node for characters moved by script.
- Description
- -----------
- Character bodies are special types of bodies that are meant to be user-controlled. They are not affected by physics at all; to other types of bodies, such as a rigid body, these are the same as a :ref:`AnimatableBody3D<class_AnimatableBody3D>`. However, they have two main uses:
- **Kinematic characters:** Character bodies have an API for moving objects with walls and slopes detection (:ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>` method), in addition to collision detection (also done with :ref:`PhysicsBody3D.move_and_collide<class_PhysicsBody3D_method_move_and_collide>`). This makes them really useful to implement characters that move in specific ways and collide with the world, but don't require advanced physics.
- **Kinematic motion:** Character bodies can also be used for kinematic motion (same functionality as :ref:`AnimatableBody3D<class_AnimatableBody3D>`), which allows them to be moved by code and push other bodies on their path.
- Tutorials
- ---------
- - :doc:`Kinematic character (2D) <../tutorials/physics/kinematic_character_2d>`
- - `3D Kinematic Character Demo <https://godotengine.org/asset-library/asset/126>`__
- - `3D Platformer Demo <https://godotengine.org/asset-library/asset/125>`__
- - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
- - `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
- Properties
- ----------
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`float<class_float>` | :ref:`collision/safe_margin<class_CharacterBody3D_property_collision/safe_margin>` | ``0.001`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`bool<class_bool>` | :ref:`floor_block_on_wall<class_CharacterBody3D_property_floor_block_on_wall>` | ``true`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`bool<class_bool>` | :ref:`floor_constant_speed<class_CharacterBody3D_property_floor_constant_speed>` | ``false`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`float<class_float>` | :ref:`floor_max_angle<class_CharacterBody3D_property_floor_max_angle>` | ``0.785398`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`float<class_float>` | :ref:`floor_snap_length<class_CharacterBody3D_property_floor_snap_length>` | ``0.1`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`bool<class_bool>` | :ref:`floor_stop_on_slope<class_CharacterBody3D_property_floor_stop_on_slope>` | ``true`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`int<class_int>` | :ref:`max_slides<class_CharacterBody3D_property_max_slides>` | ``6`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` | :ref:`motion_mode<class_CharacterBody3D_property_motion_mode>` | ``0`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`motion_velocity<class_CharacterBody3D_property_motion_velocity>` | ``Vector3(0, 0, 0)`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`MovingPlatformApplyVelocityOnLeave<enum_CharacterBody3D_MovingPlatformApplyVelocityOnLeave>` | :ref:`moving_platform_apply_velocity_on_leave<class_CharacterBody3D_property_moving_platform_apply_velocity_on_leave>` | ``0`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`int<class_int>` | :ref:`moving_platform_floor_layers<class_CharacterBody3D_property_moving_platform_floor_layers>` | ``4294967295`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`int<class_int>` | :ref:`moving_platform_wall_layers<class_CharacterBody3D_property_moving_platform_wall_layers>` | ``0`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`bool<class_bool>` | :ref:`slide_on_ceiling<class_CharacterBody3D_property_slide_on_ceiling>` | ``true`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`up_direction<class_CharacterBody3D_property_up_direction>` | ``Vector3(0, 1, 0)`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- | :ref:`float<class_float>` | :ref:`wall_min_slide_angle<class_CharacterBody3D_property_wall_min_slide_angle>` | ``0.261799`` |
- +----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+----------------------+
- Methods
- -------
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`get_floor_angle<class_CharacterBody3D_method_get_floor_angle>` **(** :ref:`Vector3<class_Vector3>` up_direction=Vector3(0, 1, 0) **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`get_floor_normal<class_CharacterBody3D_method_get_floor_normal>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`get_last_motion<class_CharacterBody3D_method_get_last_motion>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`KinematicCollision3D<class_KinematicCollision3D>` | :ref:`get_last_slide_collision<class_CharacterBody3D_method_get_last_slide_collision>` **(** **)** |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`get_platform_velocity<class_CharacterBody3D_method_get_platform_velocity>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`get_position_delta<class_CharacterBody3D_method_get_position_delta>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`get_real_velocity<class_CharacterBody3D_method_get_real_velocity>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`KinematicCollision3D<class_KinematicCollision3D>` | :ref:`get_slide_collision<class_CharacterBody3D_method_get_slide_collision>` **(** :ref:`int<class_int>` slide_idx **)** |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_slide_collision_count<class_CharacterBody3D_method_get_slide_collision_count>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Vector3<class_Vector3>` | :ref:`get_wall_normal<class_CharacterBody3D_method_get_wall_normal>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_on_ceiling<class_CharacterBody3D_method_is_on_ceiling>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_on_ceiling_only<class_CharacterBody3D_method_is_on_ceiling_only>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_on_floor<class_CharacterBody3D_method_is_on_floor>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_on_floor_only<class_CharacterBody3D_method_is_on_floor_only>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_on_wall<class_CharacterBody3D_method_is_on_wall>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_on_wall_only<class_CharacterBody3D_method_is_on_wall_only>` **(** **)** |const| |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>` **(** **)** |
- +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
- Enumerations
- ------------
- .. _enum_CharacterBody3D_MotionMode:
- .. _class_CharacterBody3D_constant_MOTION_MODE_GROUNDED:
- .. _class_CharacterBody3D_constant_MOTION_MODE_FREE:
- enum **MotionMode**:
- - **MOTION_MODE_GROUNDED** = **0** --- Apply when notions of walls, ceiling and floor are relevant. In this mode the body motion will react to slopes (acceleration/slowdown). This mode is suitable for grounded games like platformers.
- - **MOTION_MODE_FREE** = **1** --- Apply when there is no notion of floor or ceiling. All collisions will be reported as ``on_wall``. In this mode, when you slide, the speed will always be constant. This mode is suitable for games without ground like space games.
- ----
- .. _enum_CharacterBody3D_MovingPlatformApplyVelocityOnLeave:
- .. _class_CharacterBody3D_constant_PLATFORM_VEL_ON_LEAVE_ALWAYS:
- .. _class_CharacterBody3D_constant_PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY:
- .. _class_CharacterBody3D_constant_PLATFORM_VEL_ON_LEAVE_NEVER:
- enum **MovingPlatformApplyVelocityOnLeave**:
- - **PLATFORM_VEL_ON_LEAVE_ALWAYS** = **0** --- Add the last platform velocity to the :ref:`motion_velocity<class_CharacterBody3D_property_motion_velocity>` when you leave a moving platform.
- - **PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY** = **1** --- Add the last platform velocity to the :ref:`motion_velocity<class_CharacterBody3D_property_motion_velocity>` when you leave a moving platform, but any downward motion is ignored. It's useful to keep full jump height even when the platform is moving down.
- - **PLATFORM_VEL_ON_LEAVE_NEVER** = **2** --- Do nothing when leaving a platform.
- Property Descriptions
- ---------------------
- .. _class_CharacterBody3D_property_collision/safe_margin:
- - :ref:`float<class_float>` **collision/safe_margin**
- +-----------+------------------------+
- | *Default* | ``0.001`` |
- +-----------+------------------------+
- | *Setter* | set_safe_margin(value) |
- +-----------+------------------------+
- | *Getter* | get_safe_margin() |
- +-----------+------------------------+
- Extra margin used for collision recovery when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
- If the body is at least this close to another body, it will consider them to be colliding and will be pushed away before performing the actual motion.
- A higher value means it's more flexible for detecting collision, which helps with consistently detecting walls and floors.
- A lower value forces the collision algorithm to use more exact detection, so it can be used in cases that specifically require precision, e.g at very low scale to avoid visible jittering, or for stability with a stack of character bodies.
- ----
- .. _class_CharacterBody3D_property_floor_block_on_wall:
- - :ref:`bool<class_bool>` **floor_block_on_wall**
- +-----------+----------------------------------------+
- | *Default* | ``true`` |
- +-----------+----------------------------------------+
- | *Setter* | set_floor_block_on_wall_enabled(value) |
- +-----------+----------------------------------------+
- | *Getter* | is_floor_block_on_wall_enabled() |
- +-----------+----------------------------------------+
- If ``true``, the body will be able to move on the floor only. This option avoids to be able to walk on walls, it will however allow to slide down along them.
- ----
- .. _class_CharacterBody3D_property_floor_constant_speed:
- - :ref:`bool<class_bool>` **floor_constant_speed**
- +-----------+-----------------------------------------+
- | *Default* | ``false`` |
- +-----------+-----------------------------------------+
- | *Setter* | set_floor_constant_speed_enabled(value) |
- +-----------+-----------------------------------------+
- | *Getter* | is_floor_constant_speed_enabled() |
- +-----------+-----------------------------------------+
- If ``false`` (by default), the body will move faster on downward slopes and slower on upward slopes.
- If ``true``, the body will always move at the same speed on the ground no matter the slope. Note that you need to use :ref:`floor_snap_length<class_CharacterBody3D_property_floor_snap_length>` to stick along a downward slope at constant speed.
- ----
- .. _class_CharacterBody3D_property_floor_max_angle:
- - :ref:`float<class_float>` **floor_max_angle**
- +-----------+----------------------------+
- | *Default* | ``0.785398`` |
- +-----------+----------------------------+
- | *Setter* | set_floor_max_angle(value) |
- +-----------+----------------------------+
- | *Getter* | get_floor_max_angle() |
- +-----------+----------------------------+
- Maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall, when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. The default value equals 45 degrees.
- ----
- .. _class_CharacterBody3D_property_floor_snap_length:
- - :ref:`float<class_float>` **floor_snap_length**
- +-----------+------------------------------+
- | *Default* | ``0.1`` |
- +-----------+------------------------------+
- | *Setter* | set_floor_snap_length(value) |
- +-----------+------------------------------+
- | *Getter* | get_floor_snap_length() |
- +-----------+------------------------------+
- Sets a snapping distance. When set to a value different from ``0.0``, the body is kept attached to slopes when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. The snapping vector is determined by the given distance along the opposite direction of the :ref:`up_direction<class_CharacterBody3D_property_up_direction>`.
- As long as the snapping vector is in contact with the ground and the body moves against `up_direction`, the body will remain attached to the surface. Snapping is not applied if the body moves along `up_direction`, so it will be able to detach from the ground when jumping.
- ----
- .. _class_CharacterBody3D_property_floor_stop_on_slope:
- - :ref:`bool<class_bool>` **floor_stop_on_slope**
- +-----------+----------------------------------------+
- | *Default* | ``true`` |
- +-----------+----------------------------------------+
- | *Setter* | set_floor_stop_on_slope_enabled(value) |
- +-----------+----------------------------------------+
- | *Getter* | is_floor_stop_on_slope_enabled() |
- +-----------+----------------------------------------+
- If ``true``, the body will not slide on slopes when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>` when the body is standing still.
- If ``false``, the body will slide on floor's slopes when :ref:`motion_velocity<class_CharacterBody3D_property_motion_velocity>` applies a downward force.
- ----
- .. _class_CharacterBody3D_property_max_slides:
- - :ref:`int<class_int>` **max_slides**
- +-----------+-----------------------+
- | *Default* | ``6`` |
- +-----------+-----------------------+
- | *Setter* | set_max_slides(value) |
- +-----------+-----------------------+
- | *Getter* | get_max_slides() |
- +-----------+-----------------------+
- Maximum number of times the body can change direction before it stops when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
- ----
- .. _class_CharacterBody3D_property_motion_mode:
- - :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` **motion_mode**
- +-----------+------------------------+
- | *Default* | ``0`` |
- +-----------+------------------------+
- | *Setter* | set_motion_mode(value) |
- +-----------+------------------------+
- | *Getter* | get_motion_mode() |
- +-----------+------------------------+
- Sets the motion mode which defines the behaviour of :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. See :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` constants for available modes.
- ----
- .. _class_CharacterBody3D_property_motion_velocity:
- - :ref:`Vector3<class_Vector3>` **motion_velocity**
- +-----------+----------------------------+
- | *Default* | ``Vector3(0, 0, 0)`` |
- +-----------+----------------------------+
- | *Setter* | set_motion_velocity(value) |
- +-----------+----------------------------+
- | *Getter* | get_motion_velocity() |
- +-----------+----------------------------+
- Current velocity vector (typically meters per second), used and modified during calls to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
- ----
- .. _class_CharacterBody3D_property_moving_platform_apply_velocity_on_leave:
- - :ref:`MovingPlatformApplyVelocityOnLeave<enum_CharacterBody3D_MovingPlatformApplyVelocityOnLeave>` **moving_platform_apply_velocity_on_leave**
- +-----------+----------------------------------------------------+
- | *Default* | ``0`` |
- +-----------+----------------------------------------------------+
- | *Setter* | set_moving_platform_apply_velocity_on_leave(value) |
- +-----------+----------------------------------------------------+
- | *Getter* | get_moving_platform_apply_velocity_on_leave() |
- +-----------+----------------------------------------------------+
- Sets the behaviour to apply when you leave a moving platform. By default, to be physically accurate, when you leave the last platform velocity is applied. See :ref:`MovingPlatformApplyVelocityOnLeave<enum_CharacterBody3D_MovingPlatformApplyVelocityOnLeave>` constants for available behaviour.
- ----
- .. _class_CharacterBody3D_property_moving_platform_floor_layers:
- - :ref:`int<class_int>` **moving_platform_floor_layers**
- +-----------+-----------------------------------------+
- | *Default* | ``4294967295`` |
- +-----------+-----------------------------------------+
- | *Setter* | set_moving_platform_floor_layers(value) |
- +-----------+-----------------------------------------+
- | *Getter* | get_moving_platform_floor_layers() |
- +-----------+-----------------------------------------+
- Collision layers that will be included for detecting floor bodies that will act as moving platforms to be followed by the :ref:`CharacterBody2D<class_CharacterBody2D>`. By default, all floor bodies are detected and propagate their velocity.
- ----
- .. _class_CharacterBody3D_property_moving_platform_wall_layers:
- - :ref:`int<class_int>` **moving_platform_wall_layers**
- +-----------+----------------------------------------+
- | *Default* | ``0`` |
- +-----------+----------------------------------------+
- | *Setter* | set_moving_platform_wall_layers(value) |
- +-----------+----------------------------------------+
- | *Getter* | get_moving_platform_wall_layers() |
- +-----------+----------------------------------------+
- Collision layers that will be included for detecting wall bodies that will act as moving platforms to be followed by the :ref:`CharacterBody2D<class_CharacterBody2D>`. By default, all wall bodies are ignored.
- ----
- .. _class_CharacterBody3D_property_slide_on_ceiling:
- - :ref:`bool<class_bool>` **slide_on_ceiling**
- +-----------+-------------------------------------+
- | *Default* | ``true`` |
- +-----------+-------------------------------------+
- | *Setter* | set_slide_on_ceiling_enabled(value) |
- +-----------+-------------------------------------+
- | *Getter* | is_slide_on_ceiling_enabled() |
- +-----------+-------------------------------------+
- If ``true``, during a jump against the ceiling, the body will slide, if ``false`` it will be stopped and will fall vertically.
- ----
- .. _class_CharacterBody3D_property_up_direction:
- - :ref:`Vector3<class_Vector3>` **up_direction**
- +-----------+-------------------------+
- | *Default* | ``Vector3(0, 1, 0)`` |
- +-----------+-------------------------+
- | *Setter* | set_up_direction(value) |
- +-----------+-------------------------+
- | *Getter* | get_up_direction() |
- +-----------+-------------------------+
- Direction vector used to determine what is a wall and what is a floor (or a ceiling), rather than a wall, when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Defaults to ``Vector3.UP``. If set to ``Vector3(0, 0, 0)``, everything is considered a wall. This is useful for topdown games.
- ----
- .. _class_CharacterBody3D_property_wall_min_slide_angle:
- - :ref:`float<class_float>` **wall_min_slide_angle**
- +-----------+---------------------------------+
- | *Default* | ``0.261799`` |
- +-----------+---------------------------------+
- | *Setter* | set_wall_min_slide_angle(value) |
- +-----------+---------------------------------+
- | *Getter* | get_wall_min_slide_angle() |
- +-----------+---------------------------------+
- Minimum angle (in radians) where the body is allowed to slide when it encounters a slope. The default value equals 15 degrees. In ``MOTION_MODE_GROUNDED``, it works only when :ref:`floor_block_on_wall<class_CharacterBody3D_property_floor_block_on_wall>` is ``true``.
- Method Descriptions
- -------------------
- .. _class_CharacterBody3D_method_get_floor_angle:
- - :ref:`float<class_float>` **get_floor_angle** **(** :ref:`Vector3<class_Vector3>` up_direction=Vector3(0, 1, 0) **)** |const|
- Returns the floor's collision angle at the last collision point according to ``up_direction``, which is ``Vector3.UP`` by default. This value is always positive and only valid after calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>` and when :ref:`is_on_floor<class_CharacterBody3D_method_is_on_floor>` returns ``true``.
- ----
- .. _class_CharacterBody3D_method_get_floor_normal:
- - :ref:`Vector3<class_Vector3>` **get_floor_normal** **(** **)** |const|
- Returns the surface normal of the floor at the last collision point. Only valid after calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>` and when :ref:`is_on_floor<class_CharacterBody3D_method_is_on_floor>` returns ``true``.
- ----
- .. _class_CharacterBody3D_method_get_last_motion:
- - :ref:`Vector3<class_Vector3>` **get_last_motion** **(** **)** |const|
- Returns the last motion applied to the ``CharacterBody3D`` during the last call to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. The movement can be split into multiple motions when sliding occurs, and this method return the last one, which is useful to retrieve the current direction of the movement.
- ----
- .. _class_CharacterBody3D_method_get_last_slide_collision:
- - :ref:`KinematicCollision3D<class_KinematicCollision3D>` **get_last_slide_collision** **(** **)**
- Returns a :ref:`KinematicCollision3D<class_KinematicCollision3D>`, which contains information about the latest collision that occurred during the last call to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
- ----
- .. _class_CharacterBody3D_method_get_platform_velocity:
- - :ref:`Vector3<class_Vector3>` **get_platform_velocity** **(** **)** |const|
- Returns the linear velocity of the floor at the last collision point. Only valid after calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>` and when :ref:`is_on_floor<class_CharacterBody3D_method_is_on_floor>` returns ``true``.
- ----
- .. _class_CharacterBody3D_method_get_position_delta:
- - :ref:`Vector3<class_Vector3>` **get_position_delta** **(** **)** |const|
- Returns the travel (position delta) that occurred during the last call to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
- ----
- .. _class_CharacterBody3D_method_get_real_velocity:
- - :ref:`Vector3<class_Vector3>` **get_real_velocity** **(** **)** |const|
- Returns the current real velocity since the last call to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. For example, when you climb a slope, you will move diagonally even though the velocity is horizontal. This method returns the diagonal movement, as opposed to :ref:`motion_velocity<class_CharacterBody3D_property_motion_velocity>` which returns the requested velocity.
- ----
- .. _class_CharacterBody3D_method_get_slide_collision:
- - :ref:`KinematicCollision3D<class_KinematicCollision3D>` **get_slide_collision** **(** :ref:`int<class_int>` slide_idx **)**
- Returns a :ref:`KinematicCollision3D<class_KinematicCollision3D>`, which contains information about a collision that occurred during the last call to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Since the body can collide several times in a single call to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`, you must specify the index of the collision in the range 0 to (:ref:`get_slide_collision_count<class_CharacterBody3D_method_get_slide_collision_count>` - 1).
- ----
- .. _class_CharacterBody3D_method_get_slide_collision_count:
- - :ref:`int<class_int>` **get_slide_collision_count** **(** **)** |const|
- Returns the number of times the body collided and changed direction during the last call to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
- ----
- .. _class_CharacterBody3D_method_get_wall_normal:
- - :ref:`Vector3<class_Vector3>` **get_wall_normal** **(** **)** |const|
- Returns the surface normal of the wall at the last collision point. Only valid after calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>` and when :ref:`is_on_wall<class_CharacterBody3D_method_is_on_wall>` returns ``true``.
- ----
- .. _class_CharacterBody3D_method_is_on_ceiling:
- - :ref:`bool<class_bool>` **is_on_ceiling** **(** **)** |const|
- Returns ``true`` if the body collided with the ceiling on the last call of :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Otherwise, returns ``false``.
- ----
- .. _class_CharacterBody3D_method_is_on_ceiling_only:
- - :ref:`bool<class_bool>` **is_on_ceiling_only** **(** **)** |const|
- Returns ``true`` if the body collided only with the ceiling on the last call of :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Otherwise, returns ``false``.
- ----
- .. _class_CharacterBody3D_method_is_on_floor:
- - :ref:`bool<class_bool>` **is_on_floor** **(** **)** |const|
- Returns ``true`` if the body collided with the floor on the last call of :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Otherwise, returns ``false``.
- ----
- .. _class_CharacterBody3D_method_is_on_floor_only:
- - :ref:`bool<class_bool>` **is_on_floor_only** **(** **)** |const|
- Returns ``true`` if the body collided only with the floor on the last call of :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Otherwise, returns ``false``.
- ----
- .. _class_CharacterBody3D_method_is_on_wall:
- - :ref:`bool<class_bool>` **is_on_wall** **(** **)** |const|
- Returns ``true`` if the body collided with a wall on the last call of :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Otherwise, returns ``false``.
- ----
- .. _class_CharacterBody3D_method_is_on_wall_only:
- - :ref:`bool<class_bool>` **is_on_wall_only** **(** **)** |const|
- Returns ``true`` if the body collided only with a wall on the last call of :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Otherwise, returns ``false``.
- ----
- .. _class_CharacterBody3D_method_move_and_slide:
- - :ref:`bool<class_bool>` **move_and_slide** **(** **)**
- Moves the body based on :ref:`motion_velocity<class_CharacterBody3D_property_motion_velocity>`. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a ``CharacterBody3D`` or :ref:`RigidDynamicBody3D<class_RigidDynamicBody3D>`, it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
- This method should be used in :ref:`Node._physics_process<class_Node_method__physics_process>` (or in a method called by :ref:`Node._physics_process<class_Node_method__physics_process>`), as it uses the physics step's ``delta`` value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
- Modifies :ref:`motion_velocity<class_CharacterBody3D_property_motion_velocity>` if a slide collision occurred. To get the latest collision call :ref:`get_last_slide_collision<class_CharacterBody3D_method_get_last_slide_collision>`, for more detailed information about collisions that occurred, use :ref:`get_slide_collision<class_CharacterBody3D_method_get_slide_collision>`.
- When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions.
- Returns ``true`` if the body collided, otherwise, returns ``false``.
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
- .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
- .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
- .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|