class_characterbody3d.rst 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/CharacterBody3D.xml.
  6. .. _class_CharacterBody3D:
  7. CharacterBody3D
  8. ===============
  9. **Inherits:** :ref:`PhysicsBody3D<class_PhysicsBody3D>` **<** :ref:`CollisionObject3D<class_CollisionObject3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Specialized 3D physics body node for characters moved by script.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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:
  15. \ **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.
  16. \ **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.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`Kinematic character (2D) <../tutorials/physics/kinematic_character_2d>`
  21. - `3D Kinematic Character Demo <https://godotengine.org/asset-library/asset/126>`__
  22. - `3D Platformer Demo <https://godotengine.org/asset-library/asset/125>`__
  23. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
  24. - `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
  25. .. rst-class:: classref-reftable-group
  26. Properties
  27. ----------
  28. .. table::
  29. :widths: auto
  30. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  31. | :ref:`bool<class_bool>` | :ref:`floor_block_on_wall<class_CharacterBody3D_property_floor_block_on_wall>` | ``true`` |
  32. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  33. | :ref:`bool<class_bool>` | :ref:`floor_constant_speed<class_CharacterBody3D_property_floor_constant_speed>` | ``false`` |
  34. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  35. | :ref:`float<class_float>` | :ref:`floor_max_angle<class_CharacterBody3D_property_floor_max_angle>` | ``0.785398`` |
  36. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  37. | :ref:`float<class_float>` | :ref:`floor_snap_length<class_CharacterBody3D_property_floor_snap_length>` | ``0.1`` |
  38. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  39. | :ref:`bool<class_bool>` | :ref:`floor_stop_on_slope<class_CharacterBody3D_property_floor_stop_on_slope>` | ``true`` |
  40. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  41. | :ref:`int<class_int>` | :ref:`max_slides<class_CharacterBody3D_property_max_slides>` | ``6`` |
  42. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  43. | :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` | :ref:`motion_mode<class_CharacterBody3D_property_motion_mode>` | ``0`` |
  44. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  45. | :ref:`int<class_int>` | :ref:`platform_floor_layers<class_CharacterBody3D_property_platform_floor_layers>` | ``4294967295`` |
  46. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  47. | :ref:`PlatformOnLeave<enum_CharacterBody3D_PlatformOnLeave>` | :ref:`platform_on_leave<class_CharacterBody3D_property_platform_on_leave>` | ``0`` |
  48. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  49. | :ref:`int<class_int>` | :ref:`platform_wall_layers<class_CharacterBody3D_property_platform_wall_layers>` | ``0`` |
  50. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  51. | :ref:`float<class_float>` | :ref:`safe_margin<class_CharacterBody3D_property_safe_margin>` | ``0.001`` |
  52. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  53. | :ref:`bool<class_bool>` | :ref:`slide_on_ceiling<class_CharacterBody3D_property_slide_on_ceiling>` | ``true`` |
  54. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  55. | :ref:`Vector3<class_Vector3>` | :ref:`up_direction<class_CharacterBody3D_property_up_direction>` | ``Vector3(0, 1, 0)`` |
  56. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  57. | :ref:`Vector3<class_Vector3>` | :ref:`velocity<class_CharacterBody3D_property_velocity>` | ``Vector3(0, 0, 0)`` |
  58. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  59. | :ref:`float<class_float>` | :ref:`wall_min_slide_angle<class_CharacterBody3D_property_wall_min_slide_angle>` | ``0.261799`` |
  60. +--------------------------------------------------------------+------------------------------------------------------------------------------------+----------------------+
  61. .. rst-class:: classref-reftable-group
  62. Methods
  63. -------
  64. .. table::
  65. :widths: auto
  66. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :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| |
  68. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Vector3<class_Vector3>` | :ref:`get_floor_normal<class_CharacterBody3D_method_get_floor_normal>` **(** **)** |const| |
  70. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Vector3<class_Vector3>` | :ref:`get_last_motion<class_CharacterBody3D_method_get_last_motion>` **(** **)** |const| |
  72. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`KinematicCollision3D<class_KinematicCollision3D>` | :ref:`get_last_slide_collision<class_CharacterBody3D_method_get_last_slide_collision>` **(** **)** |
  74. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`Vector3<class_Vector3>` | :ref:`get_platform_angular_velocity<class_CharacterBody3D_method_get_platform_angular_velocity>` **(** **)** |const| |
  76. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`Vector3<class_Vector3>` | :ref:`get_platform_velocity<class_CharacterBody3D_method_get_platform_velocity>` **(** **)** |const| |
  78. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`Vector3<class_Vector3>` | :ref:`get_position_delta<class_CharacterBody3D_method_get_position_delta>` **(** **)** |const| |
  80. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`Vector3<class_Vector3>` | :ref:`get_real_velocity<class_CharacterBody3D_method_get_real_velocity>` **(** **)** |const| |
  82. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`KinematicCollision3D<class_KinematicCollision3D>` | :ref:`get_slide_collision<class_CharacterBody3D_method_get_slide_collision>` **(** :ref:`int<class_int>` slide_idx **)** |
  84. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`int<class_int>` | :ref:`get_slide_collision_count<class_CharacterBody3D_method_get_slide_collision_count>` **(** **)** |const| |
  86. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`Vector3<class_Vector3>` | :ref:`get_wall_normal<class_CharacterBody3D_method_get_wall_normal>` **(** **)** |const| |
  88. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`bool<class_bool>` | :ref:`is_on_ceiling<class_CharacterBody3D_method_is_on_ceiling>` **(** **)** |const| |
  90. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`bool<class_bool>` | :ref:`is_on_ceiling_only<class_CharacterBody3D_method_is_on_ceiling_only>` **(** **)** |const| |
  92. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`bool<class_bool>` | :ref:`is_on_floor<class_CharacterBody3D_method_is_on_floor>` **(** **)** |const| |
  94. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`bool<class_bool>` | :ref:`is_on_floor_only<class_CharacterBody3D_method_is_on_floor_only>` **(** **)** |const| |
  96. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`bool<class_bool>` | :ref:`is_on_wall<class_CharacterBody3D_method_is_on_wall>` **(** **)** |const| |
  98. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`is_on_wall_only<class_CharacterBody3D_method_is_on_wall_only>` **(** **)** |const| |
  100. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`bool<class_bool>` | :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>` **(** **)** |
  102. +---------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. .. rst-class:: classref-section-separator
  104. ----
  105. .. rst-class:: classref-descriptions-group
  106. Enumerations
  107. ------------
  108. .. _enum_CharacterBody3D_MotionMode:
  109. .. rst-class:: classref-enumeration
  110. enum **MotionMode**:
  111. .. _class_CharacterBody3D_constant_MOTION_MODE_GROUNDED:
  112. .. rst-class:: classref-enumeration-constant
  113. :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` **MOTION_MODE_GROUNDED** = ``0``
  114. 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.
  115. .. _class_CharacterBody3D_constant_MOTION_MODE_FLOATING:
  116. .. rst-class:: classref-enumeration-constant
  117. :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` **MOTION_MODE_FLOATING** = ``1``
  118. 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.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _enum_CharacterBody3D_PlatformOnLeave:
  122. .. rst-class:: classref-enumeration
  123. enum **PlatformOnLeave**:
  124. .. _class_CharacterBody3D_constant_PLATFORM_ON_LEAVE_ADD_VELOCITY:
  125. .. rst-class:: classref-enumeration-constant
  126. :ref:`PlatformOnLeave<enum_CharacterBody3D_PlatformOnLeave>` **PLATFORM_ON_LEAVE_ADD_VELOCITY** = ``0``
  127. Add the last platform velocity to the :ref:`velocity<class_CharacterBody3D_property_velocity>` when you leave a moving platform.
  128. .. _class_CharacterBody3D_constant_PLATFORM_ON_LEAVE_ADD_UPWARD_VELOCITY:
  129. .. rst-class:: classref-enumeration-constant
  130. :ref:`PlatformOnLeave<enum_CharacterBody3D_PlatformOnLeave>` **PLATFORM_ON_LEAVE_ADD_UPWARD_VELOCITY** = ``1``
  131. Add the last platform velocity to the :ref:`velocity<class_CharacterBody3D_property_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.
  132. .. _class_CharacterBody3D_constant_PLATFORM_ON_LEAVE_DO_NOTHING:
  133. .. rst-class:: classref-enumeration-constant
  134. :ref:`PlatformOnLeave<enum_CharacterBody3D_PlatformOnLeave>` **PLATFORM_ON_LEAVE_DO_NOTHING** = ``2``
  135. Do nothing when leaving a platform.
  136. .. rst-class:: classref-section-separator
  137. ----
  138. .. rst-class:: classref-descriptions-group
  139. Property Descriptions
  140. ---------------------
  141. .. _class_CharacterBody3D_property_floor_block_on_wall:
  142. .. rst-class:: classref-property
  143. :ref:`bool<class_bool>` **floor_block_on_wall** = ``true``
  144. .. rst-class:: classref-property-setget
  145. - void **set_floor_block_on_wall_enabled** **(** :ref:`bool<class_bool>` value **)**
  146. - :ref:`bool<class_bool>` **is_floor_block_on_wall_enabled** **(** **)**
  147. 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.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_CharacterBody3D_property_floor_constant_speed:
  151. .. rst-class:: classref-property
  152. :ref:`bool<class_bool>` **floor_constant_speed** = ``false``
  153. .. rst-class:: classref-property-setget
  154. - void **set_floor_constant_speed_enabled** **(** :ref:`bool<class_bool>` value **)**
  155. - :ref:`bool<class_bool>` **is_floor_constant_speed_enabled** **(** **)**
  156. If ``false`` (by default), the body will move faster on downward slopes and slower on upward slopes.
  157. 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.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_CharacterBody3D_property_floor_max_angle:
  161. .. rst-class:: classref-property
  162. :ref:`float<class_float>` **floor_max_angle** = ``0.785398``
  163. .. rst-class:: classref-property-setget
  164. - void **set_floor_max_angle** **(** :ref:`float<class_float>` value **)**
  165. - :ref:`float<class_float>` **get_floor_max_angle** **(** **)**
  166. 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.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_CharacterBody3D_property_floor_snap_length:
  170. .. rst-class:: classref-property
  171. :ref:`float<class_float>` **floor_snap_length** = ``0.1``
  172. .. rst-class:: classref-property-setget
  173. - void **set_floor_snap_length** **(** :ref:`float<class_float>` value **)**
  174. - :ref:`float<class_float>` **get_floor_snap_length** **(** **)**
  175. 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>`.
  176. As long as the snapping vector is in contact with the ground and the body moves against :ref:`up_direction<class_CharacterBody3D_property_up_direction>`, the body will remain attached to the surface. Snapping is not applied if the body moves along :ref:`up_direction<class_CharacterBody3D_property_up_direction>`, so it will be able to detach from the ground when jumping.
  177. .. rst-class:: classref-item-separator
  178. ----
  179. .. _class_CharacterBody3D_property_floor_stop_on_slope:
  180. .. rst-class:: classref-property
  181. :ref:`bool<class_bool>` **floor_stop_on_slope** = ``true``
  182. .. rst-class:: classref-property-setget
  183. - void **set_floor_stop_on_slope_enabled** **(** :ref:`bool<class_bool>` value **)**
  184. - :ref:`bool<class_bool>` **is_floor_stop_on_slope_enabled** **(** **)**
  185. 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.
  186. If ``false``, the body will slide on floor's slopes when :ref:`velocity<class_CharacterBody3D_property_velocity>` applies a downward force.
  187. .. rst-class:: classref-item-separator
  188. ----
  189. .. _class_CharacterBody3D_property_max_slides:
  190. .. rst-class:: classref-property
  191. :ref:`int<class_int>` **max_slides** = ``6``
  192. .. rst-class:: classref-property-setget
  193. - void **set_max_slides** **(** :ref:`int<class_int>` value **)**
  194. - :ref:`int<class_int>` **get_max_slides** **(** **)**
  195. Maximum number of times the body can change direction before it stops when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
  196. .. rst-class:: classref-item-separator
  197. ----
  198. .. _class_CharacterBody3D_property_motion_mode:
  199. .. rst-class:: classref-property
  200. :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` **motion_mode** = ``0``
  201. .. rst-class:: classref-property-setget
  202. - void **set_motion_mode** **(** :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` value **)**
  203. - :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` **get_motion_mode** **(** **)**
  204. Sets the motion mode which defines the behavior of :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. See :ref:`MotionMode<enum_CharacterBody3D_MotionMode>` constants for available modes.
  205. .. rst-class:: classref-item-separator
  206. ----
  207. .. _class_CharacterBody3D_property_platform_floor_layers:
  208. .. rst-class:: classref-property
  209. :ref:`int<class_int>` **platform_floor_layers** = ``4294967295``
  210. .. rst-class:: classref-property-setget
  211. - void **set_platform_floor_layers** **(** :ref:`int<class_int>` value **)**
  212. - :ref:`int<class_int>` **get_platform_floor_layers** **(** **)**
  213. Collision layers that will be included for detecting floor bodies that will act as moving platforms to be followed by the **CharacterBody3D**. By default, all floor bodies are detected and propagate their velocity.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_CharacterBody3D_property_platform_on_leave:
  217. .. rst-class:: classref-property
  218. :ref:`PlatformOnLeave<enum_CharacterBody3D_PlatformOnLeave>` **platform_on_leave** = ``0``
  219. .. rst-class:: classref-property-setget
  220. - void **set_platform_on_leave** **(** :ref:`PlatformOnLeave<enum_CharacterBody3D_PlatformOnLeave>` value **)**
  221. - :ref:`PlatformOnLeave<enum_CharacterBody3D_PlatformOnLeave>` **get_platform_on_leave** **(** **)**
  222. Sets the behavior 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:`PlatformOnLeave<enum_CharacterBody3D_PlatformOnLeave>` constants for available behavior.
  223. .. rst-class:: classref-item-separator
  224. ----
  225. .. _class_CharacterBody3D_property_platform_wall_layers:
  226. .. rst-class:: classref-property
  227. :ref:`int<class_int>` **platform_wall_layers** = ``0``
  228. .. rst-class:: classref-property-setget
  229. - void **set_platform_wall_layers** **(** :ref:`int<class_int>` value **)**
  230. - :ref:`int<class_int>` **get_platform_wall_layers** **(** **)**
  231. Collision layers that will be included for detecting wall bodies that will act as moving platforms to be followed by the **CharacterBody3D**. By default, all wall bodies are ignored.
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_CharacterBody3D_property_safe_margin:
  235. .. rst-class:: classref-property
  236. :ref:`float<class_float>` **safe_margin** = ``0.001``
  237. .. rst-class:: classref-property-setget
  238. - void **set_safe_margin** **(** :ref:`float<class_float>` value **)**
  239. - :ref:`float<class_float>` **get_safe_margin** **(** **)**
  240. Extra margin used for collision recovery when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
  241. 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.
  242. A higher value means it's more flexible for detecting collision, which helps with consistently detecting walls and floors.
  243. 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.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_CharacterBody3D_property_slide_on_ceiling:
  247. .. rst-class:: classref-property
  248. :ref:`bool<class_bool>` **slide_on_ceiling** = ``true``
  249. .. rst-class:: classref-property-setget
  250. - void **set_slide_on_ceiling_enabled** **(** :ref:`bool<class_bool>` value **)**
  251. - :ref:`bool<class_bool>` **is_slide_on_ceiling_enabled** **(** **)**
  252. If ``true``, during a jump against the ceiling, the body will slide, if ``false`` it will be stopped and will fall vertically.
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _class_CharacterBody3D_property_up_direction:
  256. .. rst-class:: classref-property
  257. :ref:`Vector3<class_Vector3>` **up_direction** = ``Vector3(0, 1, 0)``
  258. .. rst-class:: classref-property-setget
  259. - void **set_up_direction** **(** :ref:`Vector3<class_Vector3>` value **)**
  260. - :ref:`Vector3<class_Vector3>` **get_up_direction** **(** **)**
  261. Vector pointing upwards, used to determine what is a wall and what is a floor (or a ceiling) when calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`. Defaults to ``Vector3.UP``. As the vector will be normalized it can't be equal to :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`, if you want all collisions to be reported as walls, consider using :ref:`MOTION_MODE_FLOATING<class_CharacterBody3D_constant_MOTION_MODE_FLOATING>` as :ref:`motion_mode<class_CharacterBody3D_property_motion_mode>`.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_CharacterBody3D_property_velocity:
  265. .. rst-class:: classref-property
  266. :ref:`Vector3<class_Vector3>` **velocity** = ``Vector3(0, 0, 0)``
  267. .. rst-class:: classref-property-setget
  268. - void **set_velocity** **(** :ref:`Vector3<class_Vector3>` value **)**
  269. - :ref:`Vector3<class_Vector3>` **get_velocity** **(** **)**
  270. Current velocity vector (typically meters per second), used and modified during calls to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_CharacterBody3D_property_wall_min_slide_angle:
  274. .. rst-class:: classref-property
  275. :ref:`float<class_float>` **wall_min_slide_angle** = ``0.261799``
  276. .. rst-class:: classref-property-setget
  277. - void **set_wall_min_slide_angle** **(** :ref:`float<class_float>` value **)**
  278. - :ref:`float<class_float>` **get_wall_min_slide_angle** **(** **)**
  279. Minimum angle (in radians) where the body is allowed to slide when it encounters a slope. The default value equals 15 degrees. When :ref:`motion_mode<class_CharacterBody3D_property_motion_mode>` is :ref:`MOTION_MODE_GROUNDED<class_CharacterBody3D_constant_MOTION_MODE_GROUNDED>`, it only affects movement if :ref:`floor_block_on_wall<class_CharacterBody3D_property_floor_block_on_wall>` is ``true``.
  280. .. rst-class:: classref-section-separator
  281. ----
  282. .. rst-class:: classref-descriptions-group
  283. Method Descriptions
  284. -------------------
  285. .. _class_CharacterBody3D_method_get_floor_angle:
  286. .. rst-class:: classref-method
  287. :ref:`float<class_float>` **get_floor_angle** **(** :ref:`Vector3<class_Vector3>` up_direction=Vector3(0, 1, 0) **)** |const|
  288. 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``.
  289. .. rst-class:: classref-item-separator
  290. ----
  291. .. _class_CharacterBody3D_method_get_floor_normal:
  292. .. rst-class:: classref-method
  293. :ref:`Vector3<class_Vector3>` **get_floor_normal** **(** **)** |const|
  294. 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``.
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. _class_CharacterBody3D_method_get_last_motion:
  298. .. rst-class:: classref-method
  299. :ref:`Vector3<class_Vector3>` **get_last_motion** **(** **)** |const|
  300. 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.
  301. .. rst-class:: classref-item-separator
  302. ----
  303. .. _class_CharacterBody3D_method_get_last_slide_collision:
  304. .. rst-class:: classref-method
  305. :ref:`KinematicCollision3D<class_KinematicCollision3D>` **get_last_slide_collision** **(** **)**
  306. 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>`.
  307. .. rst-class:: classref-item-separator
  308. ----
  309. .. _class_CharacterBody3D_method_get_platform_angular_velocity:
  310. .. rst-class:: classref-method
  311. :ref:`Vector3<class_Vector3>` **get_platform_angular_velocity** **(** **)** |const|
  312. Returns the angular velocity of the platform at the last collision point. Only valid after calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
  313. .. rst-class:: classref-item-separator
  314. ----
  315. .. _class_CharacterBody3D_method_get_platform_velocity:
  316. .. rst-class:: classref-method
  317. :ref:`Vector3<class_Vector3>` **get_platform_velocity** **(** **)** |const|
  318. Returns the linear velocity of the platform at the last collision point. Only valid after calling :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
  319. .. rst-class:: classref-item-separator
  320. ----
  321. .. _class_CharacterBody3D_method_get_position_delta:
  322. .. rst-class:: classref-method
  323. :ref:`Vector3<class_Vector3>` **get_position_delta** **(** **)** |const|
  324. Returns the travel (position delta) that occurred during the last call to :ref:`move_and_slide<class_CharacterBody3D_method_move_and_slide>`.
  325. .. rst-class:: classref-item-separator
  326. ----
  327. .. _class_CharacterBody3D_method_get_real_velocity:
  328. .. rst-class:: classref-method
  329. :ref:`Vector3<class_Vector3>` **get_real_velocity** **(** **)** |const|
  330. 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:`velocity<class_CharacterBody3D_property_velocity>` which returns the requested velocity.
  331. .. rst-class:: classref-item-separator
  332. ----
  333. .. _class_CharacterBody3D_method_get_slide_collision:
  334. .. rst-class:: classref-method
  335. :ref:`KinematicCollision3D<class_KinematicCollision3D>` **get_slide_collision** **(** :ref:`int<class_int>` slide_idx **)**
  336. 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).
  337. .. rst-class:: classref-item-separator
  338. ----
  339. .. _class_CharacterBody3D_method_get_slide_collision_count:
  340. .. rst-class:: classref-method
  341. :ref:`int<class_int>` **get_slide_collision_count** **(** **)** |const|
  342. 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>`.
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_CharacterBody3D_method_get_wall_normal:
  346. .. rst-class:: classref-method
  347. :ref:`Vector3<class_Vector3>` **get_wall_normal** **(** **)** |const|
  348. 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``.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_CharacterBody3D_method_is_on_ceiling:
  352. .. rst-class:: classref-method
  353. :ref:`bool<class_bool>` **is_on_ceiling** **(** **)** |const|
  354. 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``. The :ref:`up_direction<class_CharacterBody3D_property_up_direction>` and :ref:`floor_max_angle<class_CharacterBody3D_property_floor_max_angle>` are used to determine whether a surface is "ceiling" or not.
  355. .. rst-class:: classref-item-separator
  356. ----
  357. .. _class_CharacterBody3D_method_is_on_ceiling_only:
  358. .. rst-class:: classref-method
  359. :ref:`bool<class_bool>` **is_on_ceiling_only** **(** **)** |const|
  360. 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``. The :ref:`up_direction<class_CharacterBody3D_property_up_direction>` and :ref:`floor_max_angle<class_CharacterBody3D_property_floor_max_angle>` are used to determine whether a surface is "ceiling" or not.
  361. .. rst-class:: classref-item-separator
  362. ----
  363. .. _class_CharacterBody3D_method_is_on_floor:
  364. .. rst-class:: classref-method
  365. :ref:`bool<class_bool>` **is_on_floor** **(** **)** |const|
  366. 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``. The :ref:`up_direction<class_CharacterBody3D_property_up_direction>` and :ref:`floor_max_angle<class_CharacterBody3D_property_floor_max_angle>` are used to determine whether a surface is "floor" or not.
  367. .. rst-class:: classref-item-separator
  368. ----
  369. .. _class_CharacterBody3D_method_is_on_floor_only:
  370. .. rst-class:: classref-method
  371. :ref:`bool<class_bool>` **is_on_floor_only** **(** **)** |const|
  372. 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``. The :ref:`up_direction<class_CharacterBody3D_property_up_direction>` and :ref:`floor_max_angle<class_CharacterBody3D_property_floor_max_angle>` are used to determine whether a surface is "floor" or not.
  373. .. rst-class:: classref-item-separator
  374. ----
  375. .. _class_CharacterBody3D_method_is_on_wall:
  376. .. rst-class:: classref-method
  377. :ref:`bool<class_bool>` **is_on_wall** **(** **)** |const|
  378. 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``. The :ref:`up_direction<class_CharacterBody3D_property_up_direction>` and :ref:`floor_max_angle<class_CharacterBody3D_property_floor_max_angle>` are used to determine whether a surface is "wall" or not.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_CharacterBody3D_method_is_on_wall_only:
  382. .. rst-class:: classref-method
  383. :ref:`bool<class_bool>` **is_on_wall_only** **(** **)** |const|
  384. 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``. The :ref:`up_direction<class_CharacterBody3D_property_up_direction>` and :ref:`floor_max_angle<class_CharacterBody3D_property_floor_max_angle>` are used to determine whether a surface is "wall" or not.
  385. .. rst-class:: classref-item-separator
  386. ----
  387. .. _class_CharacterBody3D_method_move_and_slide:
  388. .. rst-class:: classref-method
  389. :ref:`bool<class_bool>` **move_and_slide** **(** **)**
  390. Moves the body based on :ref:`velocity<class_CharacterBody3D_property_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:`RigidBody3D<class_RigidBody3D>`, 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.
  391. Modifies :ref:`velocity<class_CharacterBody3D_property_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>`.
  392. 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.
  393. Returns ``true`` if the body collided, otherwise, returns ``false``.
  394. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  395. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  396. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  397. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  398. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  399. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`