class_kinematicbody.rst 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/KinematicBody.xml.
  6. .. _class_KinematicBody:
  7. KinematicBody
  8. =============
  9. **Inherits:** :ref:`PhysicsBody<class_PhysicsBody>` **<** :ref:`CollisionObject<class_CollisionObject>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Kinematic body 3D node.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Kinematic 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 character or a rigid body, these are the same as a static body. However, they have two main uses:
  15. \ **Simulated motion:** When these bodies are moved manually, either from code or from an :ref:`AnimationPlayer<class_AnimationPlayer>` (with :ref:`AnimationPlayer.playback_process_mode<class_AnimationPlayer_property_playback_process_mode>` set to "physics"), the physics will automatically compute an estimate of their linear and angular velocity. This makes them very useful for moving platforms or other AnimationPlayer-controlled objects (like a door, a bridge that opens, etc).
  16. \ **Kinematic characters:** KinematicBody also has an API for moving objects (the :ref:`move_and_collide<class_KinematicBody_method_move_and_collide>` and :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but don't require advanced physics.
  17. \ **Warning:** With a non-uniform scale this node will probably not function as expected. Please make sure to keep its scale uniform (i.e. the same on all axes), and change the size(s) of its collision shape(s) instead.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - :doc:`Kinematic character (2D) <../tutorials/physics/kinematic_character_2d>`
  22. - `3D Kinematic Character Demo <https://godotengine.org/asset-library/asset/126>`__
  23. - `3D Platformer Demo <https://godotengine.org/asset-library/asset/125>`__
  24. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
  25. - `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
  26. .. rst-class:: classref-reftable-group
  27. Properties
  28. ----------
  29. .. table::
  30. :widths: auto
  31. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  32. | :ref:`bool<class_bool>` | :ref:`axis_lock_motion_x<class_KinematicBody_property_axis_lock_motion_x>` | ``false`` |
  33. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  34. | :ref:`bool<class_bool>` | :ref:`axis_lock_motion_y<class_KinematicBody_property_axis_lock_motion_y>` | ``false`` |
  35. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  36. | :ref:`bool<class_bool>` | :ref:`axis_lock_motion_z<class_KinematicBody_property_axis_lock_motion_z>` | ``false`` |
  37. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  38. | :ref:`float<class_float>` | :ref:`collision/safe_margin<class_KinematicBody_property_collision/safe_margin>` | ``0.001`` |
  39. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  40. | :ref:`bool<class_bool>` | :ref:`motion/sync_to_physics<class_KinematicBody_property_motion/sync_to_physics>` | ``false`` |
  41. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  42. | :ref:`bool<class_bool>` | :ref:`move_lock_x<class_KinematicBody_property_move_lock_x>` | ``false`` |
  43. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  44. | :ref:`bool<class_bool>` | :ref:`move_lock_y<class_KinematicBody_property_move_lock_y>` | ``false`` |
  45. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  46. | :ref:`bool<class_bool>` | :ref:`move_lock_z<class_KinematicBody_property_move_lock_z>` | ``false`` |
  47. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  48. | :ref:`MovingPlatformApplyVelocityOnLeave<enum_KinematicBody_MovingPlatformApplyVelocityOnLeave>` | :ref:`moving_platform_apply_velocity_on_leave<class_KinematicBody_property_moving_platform_apply_velocity_on_leave>` | ``0`` |
  49. +--------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+-----------+
  50. .. rst-class:: classref-reftable-group
  51. Methods
  52. -------
  53. .. table::
  54. :widths: auto
  55. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`get_axis_lock<class_KinematicBody_method_get_axis_lock>` **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const| |
  57. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`float<class_float>` | :ref:`get_floor_angle<class_KinematicBody_method_get_floor_angle>` **(** :ref:`Vector3<class_Vector3>` up_direction=Vector3( 0, 1, 0 ) **)** |const| |
  59. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Vector3<class_Vector3>` | :ref:`get_floor_normal<class_KinematicBody_method_get_floor_normal>` **(** **)** |const| |
  61. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Vector3<class_Vector3>` | :ref:`get_floor_velocity<class_KinematicBody_method_get_floor_velocity>` **(** **)** |const| |
  63. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`KinematicCollision<class_KinematicCollision>` | :ref:`get_last_slide_collision<class_KinematicBody_method_get_last_slide_collision>` **(** **)** |
  65. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`KinematicCollision<class_KinematicCollision>` | :ref:`get_slide_collision<class_KinematicBody_method_get_slide_collision>` **(** :ref:`int<class_int>` slide_idx **)** |
  67. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`int<class_int>` | :ref:`get_slide_count<class_KinematicBody_method_get_slide_count>` **(** **)** |const| |
  69. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`is_on_ceiling<class_KinematicBody_method_is_on_ceiling>` **(** **)** |const| |
  71. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`is_on_floor<class_KinematicBody_method_is_on_floor>` **(** **)** |const| |
  73. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`bool<class_bool>` | :ref:`is_on_wall<class_KinematicBody_method_is_on_wall>` **(** **)** |const| |
  75. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`KinematicCollision<class_KinematicCollision>` | :ref:`move_and_collide<class_KinematicBody_method_move_and_collide>` **(** :ref:`Vector3<class_Vector3>` rel_vec, :ref:`bool<class_bool>` infinite_inertia=true, :ref:`bool<class_bool>` exclude_raycast_shapes=true, :ref:`bool<class_bool>` test_only=false **)** |
  77. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Vector3<class_Vector3>` | :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` **(** :ref:`Vector3<class_Vector3>` linear_velocity, :ref:`Vector3<class_Vector3>` up_direction=Vector3( 0, 0, 0 ), :ref:`bool<class_bool>` stop_on_slope=false, :ref:`int<class_int>` max_slides=4, :ref:`float<class_float>` floor_max_angle=0.785398, :ref:`bool<class_bool>` infinite_inertia=true **)** |
  79. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector3<class_Vector3>` | :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>` **(** :ref:`Vector3<class_Vector3>` linear_velocity, :ref:`Vector3<class_Vector3>` snap, :ref:`Vector3<class_Vector3>` up_direction=Vector3( 0, 0, 0 ), :ref:`bool<class_bool>` stop_on_slope=false, :ref:`int<class_int>` max_slides=4, :ref:`float<class_float>` floor_max_angle=0.785398, :ref:`bool<class_bool>` infinite_inertia=true **)** |
  81. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`set_axis_lock<class_KinematicBody_method_set_axis_lock>` **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)** |
  83. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`bool<class_bool>` | :ref:`test_move<class_KinematicBody_method_test_move>` **(** :ref:`Transform<class_Transform>` from, :ref:`Vector3<class_Vector3>` rel_vec, :ref:`bool<class_bool>` infinite_inertia=true **)** |
  85. +-----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. .. rst-class:: classref-section-separator
  87. ----
  88. .. rst-class:: classref-descriptions-group
  89. Enumerations
  90. ------------
  91. .. _enum_KinematicBody_MovingPlatformApplyVelocityOnLeave:
  92. .. rst-class:: classref-enumeration
  93. enum **MovingPlatformApplyVelocityOnLeave**:
  94. .. _class_KinematicBody_constant_PLATFORM_VEL_ON_LEAVE_ALWAYS:
  95. .. rst-class:: classref-enumeration-constant
  96. :ref:`MovingPlatformApplyVelocityOnLeave<enum_KinematicBody_MovingPlatformApplyVelocityOnLeave>` **PLATFORM_VEL_ON_LEAVE_ALWAYS** = ``0``
  97. Add the last platform velocity when you leave a moving platform.
  98. .. _class_KinematicBody_constant_PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY:
  99. .. rst-class:: classref-enumeration-constant
  100. :ref:`MovingPlatformApplyVelocityOnLeave<enum_KinematicBody_MovingPlatformApplyVelocityOnLeave>` **PLATFORM_VEL_ON_LEAVE_UPWARD_ONLY** = ``1``
  101. Add the last platform 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.
  102. .. _class_KinematicBody_constant_PLATFORM_VEL_ON_LEAVE_NEVER:
  103. .. rst-class:: classref-enumeration-constant
  104. :ref:`MovingPlatformApplyVelocityOnLeave<enum_KinematicBody_MovingPlatformApplyVelocityOnLeave>` **PLATFORM_VEL_ON_LEAVE_NEVER** = ``2``
  105. Do nothing when leaving a platform.
  106. .. rst-class:: classref-section-separator
  107. ----
  108. .. rst-class:: classref-descriptions-group
  109. Property Descriptions
  110. ---------------------
  111. .. _class_KinematicBody_property_axis_lock_motion_x:
  112. .. rst-class:: classref-property
  113. :ref:`bool<class_bool>` **axis_lock_motion_x** = ``false``
  114. .. rst-class:: classref-property-setget
  115. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  116. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  117. Lock the body's X axis movement.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_KinematicBody_property_axis_lock_motion_y:
  121. .. rst-class:: classref-property
  122. :ref:`bool<class_bool>` **axis_lock_motion_y** = ``false``
  123. .. rst-class:: classref-property-setget
  124. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  125. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  126. Lock the body's Y axis movement.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_KinematicBody_property_axis_lock_motion_z:
  130. .. rst-class:: classref-property
  131. :ref:`bool<class_bool>` **axis_lock_motion_z** = ``false``
  132. .. rst-class:: classref-property-setget
  133. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  134. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  135. Lock the body's Z axis movement.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_KinematicBody_property_collision/safe_margin:
  139. .. rst-class:: classref-property
  140. :ref:`float<class_float>` **collision/safe_margin** = ``0.001``
  141. .. rst-class:: classref-property-setget
  142. - void **set_safe_margin** **(** :ref:`float<class_float>` value **)**
  143. - :ref:`float<class_float>` **get_safe_margin** **(** **)**
  144. Extra margin used for collision recovery in motion functions (see :ref:`move_and_collide<class_KinematicBody_method_move_and_collide>`, :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>`, :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>`).
  145. 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.
  146. A higher value means it's more flexible for detecting collision, which helps with consistently detecting walls and floors.
  147. 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 kinematic bodies.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_KinematicBody_property_motion/sync_to_physics:
  151. .. rst-class:: classref-property
  152. :ref:`bool<class_bool>` **motion/sync_to_physics** = ``false``
  153. .. rst-class:: classref-property-setget
  154. - void **set_sync_to_physics** **(** :ref:`bool<class_bool>` value **)**
  155. - :ref:`bool<class_bool>` **is_sync_to_physics_enabled** **(** **)**
  156. If ``true``, the body's movement will be synchronized to the physics frame. This is useful when animating movement via :ref:`AnimationPlayer<class_AnimationPlayer>`, for example on moving platforms. Do **not** use together with :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` or :ref:`move_and_collide<class_KinematicBody_method_move_and_collide>` functions.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_KinematicBody_property_move_lock_x:
  160. .. rst-class:: classref-property
  161. :ref:`bool<class_bool>` **move_lock_x** = ``false``
  162. .. rst-class:: classref-property-setget
  163. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  164. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  165. Lock the body's X axis movement. Deprecated alias for :ref:`axis_lock_motion_x<class_KinematicBody_property_axis_lock_motion_x>`.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_KinematicBody_property_move_lock_y:
  169. .. rst-class:: classref-property
  170. :ref:`bool<class_bool>` **move_lock_y** = ``false``
  171. .. rst-class:: classref-property-setget
  172. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  173. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  174. Lock the body's Y axis movement. Deprecated alias for :ref:`axis_lock_motion_y<class_KinematicBody_property_axis_lock_motion_y>`.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_KinematicBody_property_move_lock_z:
  178. .. rst-class:: classref-property
  179. :ref:`bool<class_bool>` **move_lock_z** = ``false``
  180. .. rst-class:: classref-property-setget
  181. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  182. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  183. Lock the body's Z axis movement. Deprecated alias for :ref:`axis_lock_motion_z<class_KinematicBody_property_axis_lock_motion_z>`.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_KinematicBody_property_moving_platform_apply_velocity_on_leave:
  187. .. rst-class:: classref-property
  188. :ref:`MovingPlatformApplyVelocityOnLeave<enum_KinematicBody_MovingPlatformApplyVelocityOnLeave>` **moving_platform_apply_velocity_on_leave** = ``0``
  189. .. rst-class:: classref-property-setget
  190. - void **set_moving_platform_apply_velocity_on_leave** **(** :ref:`MovingPlatformApplyVelocityOnLeave<enum_KinematicBody_MovingPlatformApplyVelocityOnLeave>` value **)**
  191. - :ref:`MovingPlatformApplyVelocityOnLeave<enum_KinematicBody_MovingPlatformApplyVelocityOnLeave>` **get_moving_platform_apply_velocity_on_leave** **(** **)**
  192. 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:`MovingPlatformApplyVelocityOnLeave<enum_KinematicBody_MovingPlatformApplyVelocityOnLeave>` constants for available behavior.
  193. .. rst-class:: classref-section-separator
  194. ----
  195. .. rst-class:: classref-descriptions-group
  196. Method Descriptions
  197. -------------------
  198. .. _class_KinematicBody_method_get_axis_lock:
  199. .. rst-class:: classref-method
  200. :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  201. Returns ``true`` if the specified ``axis`` is locked. See also :ref:`move_lock_x<class_KinematicBody_property_move_lock_x>`, :ref:`move_lock_y<class_KinematicBody_property_move_lock_y>` and :ref:`move_lock_z<class_KinematicBody_property_move_lock_z>`.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_KinematicBody_method_get_floor_angle:
  205. .. rst-class:: classref-method
  206. :ref:`float<class_float>` **get_floor_angle** **(** :ref:`Vector3<class_Vector3>` up_direction=Vector3( 0, 1, 0 ) **)** |const|
  207. 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_KinematicBody_method_move_and_slide>` and when :ref:`is_on_floor<class_KinematicBody_method_is_on_floor>` returns ``true``.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_KinematicBody_method_get_floor_normal:
  211. .. rst-class:: classref-method
  212. :ref:`Vector3<class_Vector3>` **get_floor_normal** **(** **)** |const|
  213. Returns the surface normal of the floor at the last collision point. Only valid after calling :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` or :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>` and when :ref:`is_on_floor<class_KinematicBody_method_is_on_floor>` returns ``true``.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_KinematicBody_method_get_floor_velocity:
  217. .. rst-class:: classref-method
  218. :ref:`Vector3<class_Vector3>` **get_floor_velocity** **(** **)** |const|
  219. Returns the linear velocity of the floor at the last collision point. Only valid after calling :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` or :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>` and when :ref:`is_on_floor<class_KinematicBody_method_is_on_floor>` returns ``true``.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_KinematicBody_method_get_last_slide_collision:
  223. .. rst-class:: classref-method
  224. :ref:`KinematicCollision<class_KinematicCollision>` **get_last_slide_collision** **(** **)**
  225. Returns a :ref:`KinematicCollision<class_KinematicCollision>`, which contains information about the latest collision that occurred during the last call to :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>`.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _class_KinematicBody_method_get_slide_collision:
  229. .. rst-class:: classref-method
  230. :ref:`KinematicCollision<class_KinematicCollision>` **get_slide_collision** **(** :ref:`int<class_int>` slide_idx **)**
  231. Returns a :ref:`KinematicCollision<class_KinematicCollision>`, which contains information about a collision that occurred during the last call to :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` or :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>`. Since the body can collide several times in a single call to :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>`, you must specify the index of the collision in the range 0 to (:ref:`get_slide_count<class_KinematicBody_method_get_slide_count>` - 1).
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_KinematicBody_method_get_slide_count:
  235. .. rst-class:: classref-method
  236. :ref:`int<class_int>` **get_slide_count** **(** **)** |const|
  237. Returns the number of times the body collided and changed direction during the last call to :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` or :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>`.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_KinematicBody_method_is_on_ceiling:
  241. .. rst-class:: classref-method
  242. :ref:`bool<class_bool>` **is_on_ceiling** **(** **)** |const|
  243. Returns ``true`` if the body collided with the ceiling on the last call of :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` or :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>`. Otherwise, returns ``false``.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_KinematicBody_method_is_on_floor:
  247. .. rst-class:: classref-method
  248. :ref:`bool<class_bool>` **is_on_floor** **(** **)** |const|
  249. Returns ``true`` if the body collided with the floor on the last call of :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` or :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>`. Otherwise, returns ``false``.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_KinematicBody_method_is_on_wall:
  253. .. rst-class:: classref-method
  254. :ref:`bool<class_bool>` **is_on_wall** **(** **)** |const|
  255. Returns ``true`` if the body collided with a wall on the last call of :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` or :ref:`move_and_slide_with_snap<class_KinematicBody_method_move_and_slide_with_snap>`. Otherwise, returns ``false``.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_KinematicBody_method_move_and_collide:
  259. .. rst-class:: classref-method
  260. :ref:`KinematicCollision<class_KinematicCollision>` **move_and_collide** **(** :ref:`Vector3<class_Vector3>` rel_vec, :ref:`bool<class_bool>` infinite_inertia=true, :ref:`bool<class_bool>` exclude_raycast_shapes=true, :ref:`bool<class_bool>` test_only=false **)**
  261. Moves the body along the vector ``rel_vec``. The body will stop if it collides. Returns a :ref:`KinematicCollision<class_KinematicCollision>`, which contains information about the collision when stopped, or when touching another body along the motion.
  262. If ``test_only`` is ``true``, the body does not move but the would-be collision information is given.
  263. .. rst-class:: classref-item-separator
  264. ----
  265. .. _class_KinematicBody_method_move_and_slide:
  266. .. rst-class:: classref-method
  267. :ref:`Vector3<class_Vector3>` **move_and_slide** **(** :ref:`Vector3<class_Vector3>` linear_velocity, :ref:`Vector3<class_Vector3>` up_direction=Vector3( 0, 0, 0 ), :ref:`bool<class_bool>` stop_on_slope=false, :ref:`int<class_int>` max_slides=4, :ref:`float<class_float>` floor_max_angle=0.785398, :ref:`bool<class_bool>` infinite_inertia=true **)**
  268. Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a **KinematicBody** or :ref:`RigidBody<class_RigidBody>`, 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.
  269. 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.
  270. \ ``linear_velocity`` is the velocity vector (typically meters per second). Unlike in :ref:`move_and_collide<class_KinematicBody_method_move_and_collide>`, you should *not* multiply it by ``delta`` — the physics engine handles applying the velocity.
  271. \ ``up_direction`` is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of ``Vector3(0, 0, 0)``, everything is considered a wall.
  272. If ``stop_on_slope`` is ``true``, body will not slide on slopes when you include gravity in ``linear_velocity`` and the body is standing still.
  273. If the body collides, it will change direction a maximum of ``max_slides`` times before it stops.
  274. \ ``floor_max_angle`` is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees.
  275. If ``infinite_inertia`` is ``true``, body will be able to push :ref:`RigidBody<class_RigidBody>` nodes, but it won't also detect any collisions with them. If ``false``, it will interact with :ref:`RigidBody<class_RigidBody>` nodes like with :ref:`StaticBody<class_StaticBody>`.
  276. Returns the ``linear_velocity`` vector, rotated and/or scaled if a slide collision occurred. To get detailed information about collisions that occurred, use :ref:`get_slide_collision<class_KinematicBody_method_get_slide_collision>`.
  277. 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.
  278. .. rst-class:: classref-item-separator
  279. ----
  280. .. _class_KinematicBody_method_move_and_slide_with_snap:
  281. .. rst-class:: classref-method
  282. :ref:`Vector3<class_Vector3>` **move_and_slide_with_snap** **(** :ref:`Vector3<class_Vector3>` linear_velocity, :ref:`Vector3<class_Vector3>` snap, :ref:`Vector3<class_Vector3>` up_direction=Vector3( 0, 0, 0 ), :ref:`bool<class_bool>` stop_on_slope=false, :ref:`int<class_int>` max_slides=4, :ref:`float<class_float>` floor_max_angle=0.785398, :ref:`bool<class_bool>` infinite_inertia=true **)**
  283. Moves the body while keeping it attached to slopes. Similar to :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>`.
  284. As long as the ``snap`` vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting ``snap`` to ``(0, 0, 0)`` or by using :ref:`move_and_slide<class_KinematicBody_method_move_and_slide>` instead.
  285. .. rst-class:: classref-item-separator
  286. ----
  287. .. _class_KinematicBody_method_set_axis_lock:
  288. .. rst-class:: classref-method
  289. void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  290. Locks or unlocks the specified ``axis`` depending on the value of ``lock``. See also :ref:`move_lock_x<class_KinematicBody_property_move_lock_x>`, :ref:`move_lock_y<class_KinematicBody_property_move_lock_y>` and :ref:`move_lock_z<class_KinematicBody_property_move_lock_z>`.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_KinematicBody_method_test_move:
  294. .. rst-class:: classref-method
  295. :ref:`bool<class_bool>` **test_move** **(** :ref:`Transform<class_Transform>` from, :ref:`Vector3<class_Vector3>` rel_vec, :ref:`bool<class_bool>` infinite_inertia=true **)**
  296. Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given :ref:`Transform<class_Transform>`, then tries to move the body along the vector ``rel_vec``. Returns ``true`` if a collision would stop the body from moving along the whole path.
  297. Use :ref:`move_and_collide<class_KinematicBody_method_move_and_collide>` instead for detecting collision with touching bodies.
  298. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  299. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  300. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  301. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`