2
0

class_rigidbody.rst 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  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.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/RigidBody.xml.
  6. .. _class_RigidBody:
  7. RigidBody
  8. =========
  9. **Inherits:** :ref:`PhysicsBody<class_PhysicsBody>` **<** :ref:`CollisionObject<class_CollisionObject>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`VehicleBody<class_VehicleBody>`
  11. Physics Body whose position is determined through physics simulation in 3D space.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. This is the node that implements full 3D physics. This means that you do not control a RigidBody directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
  16. A RigidBody has 4 behavior :ref:`mode<class_RigidBody_property_mode>`\ s: Rigid, Static, Character, and Kinematic.
  17. \ **Note:** Don't change a RigidBody's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed Hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop may result in strange behavior. If you need to directly affect the body's state, use :ref:`_integrate_forces<class_RigidBody_method__integrate_forces>`, which allows you to directly access the physics state.
  18. If you need to override the default physics behavior, you can write a custom force integration function. See :ref:`custom_integrator<class_RigidBody_property_custom_integrator>`.
  19. With Bullet physics (the default), the center of mass is the RigidBody3D center. With GodotPhysics, the center of mass is the average of the :ref:`CollisionShape<class_CollisionShape>` centers.
  20. \ **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.
  21. .. rst-class:: classref-introduction-group
  22. Tutorials
  23. ---------
  24. - :doc:`Physics introduction <../tutorials/physics/physics_introduction>`
  25. - `3D Truck Town Demo <https://godotengine.org/asset-library/asset/524>`__
  26. - `3D Physics Tests Demo <https://godotengine.org/asset-library/asset/675>`__
  27. .. rst-class:: classref-reftable-group
  28. Properties
  29. ----------
  30. .. table::
  31. :widths: auto
  32. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  33. | :ref:`float<class_float>` | :ref:`angular_damp<class_RigidBody_property_angular_damp>` | ``-1.0`` |
  34. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  35. | :ref:`Vector3<class_Vector3>` | :ref:`angular_velocity<class_RigidBody_property_angular_velocity>` | ``Vector3( 0, 0, 0 )`` |
  36. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`axis_lock_angular_x<class_RigidBody_property_axis_lock_angular_x>` | ``false`` |
  38. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`axis_lock_angular_y<class_RigidBody_property_axis_lock_angular_y>` | ``false`` |
  40. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`axis_lock_angular_z<class_RigidBody_property_axis_lock_angular_z>` | ``false`` |
  42. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`axis_lock_linear_x<class_RigidBody_property_axis_lock_linear_x>` | ``false`` |
  44. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`axis_lock_linear_y<class_RigidBody_property_axis_lock_linear_y>` | ``false`` |
  46. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`axis_lock_linear_z<class_RigidBody_property_axis_lock_linear_z>` | ``false`` |
  48. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  49. | :ref:`float<class_float>` | :ref:`bounce<class_RigidBody_property_bounce>` | |
  50. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  51. | :ref:`bool<class_bool>` | :ref:`can_sleep<class_RigidBody_property_can_sleep>` | ``true`` |
  52. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`contact_monitor<class_RigidBody_property_contact_monitor>` | ``false`` |
  54. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  55. | :ref:`int<class_int>` | :ref:`contacts_reported<class_RigidBody_property_contacts_reported>` | ``0`` |
  56. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  57. | :ref:`bool<class_bool>` | :ref:`continuous_cd<class_RigidBody_property_continuous_cd>` | ``false`` |
  58. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`custom_integrator<class_RigidBody_property_custom_integrator>` | ``false`` |
  60. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  61. | :ref:`float<class_float>` | :ref:`friction<class_RigidBody_property_friction>` | |
  62. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  63. | :ref:`float<class_float>` | :ref:`gravity_scale<class_RigidBody_property_gravity_scale>` | ``1.0`` |
  64. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  65. | :ref:`float<class_float>` | :ref:`linear_damp<class_RigidBody_property_linear_damp>` | ``-1.0`` |
  66. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  67. | :ref:`Vector3<class_Vector3>` | :ref:`linear_velocity<class_RigidBody_property_linear_velocity>` | ``Vector3( 0, 0, 0 )`` |
  68. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  69. | :ref:`float<class_float>` | :ref:`mass<class_RigidBody_property_mass>` | ``1.0`` |
  70. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  71. | :ref:`Mode<enum_RigidBody_Mode>` | :ref:`mode<class_RigidBody_property_mode>` | ``0`` |
  72. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  73. | :ref:`PhysicsMaterial<class_PhysicsMaterial>` | :ref:`physics_material_override<class_RigidBody_property_physics_material_override>` | |
  74. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`sleeping<class_RigidBody_property_sleeping>` | ``false`` |
  76. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  77. | :ref:`float<class_float>` | :ref:`weight<class_RigidBody_property_weight>` | ``9.8`` |
  78. +-----------------------------------------------+--------------------------------------------------------------------------------------+------------------------+
  79. .. rst-class:: classref-reftable-group
  80. Methods
  81. -------
  82. .. table::
  83. :widths: auto
  84. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`_integrate_forces<class_RigidBody_method__integrate_forces>` **(** :ref:`PhysicsDirectBodyState<class_PhysicsDirectBodyState>` state **)** |virtual| |
  86. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`add_central_force<class_RigidBody_method_add_central_force>` **(** :ref:`Vector3<class_Vector3>` force **)** |
  88. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`add_force<class_RigidBody_method_add_force>` **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position **)** |
  90. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`add_torque<class_RigidBody_method_add_torque>` **(** :ref:`Vector3<class_Vector3>` torque **)** |
  92. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`apply_central_impulse<class_RigidBody_method_apply_central_impulse>` **(** :ref:`Vector3<class_Vector3>` impulse **)** |
  94. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`apply_impulse<class_RigidBody_method_apply_impulse>` **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` impulse **)** |
  96. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`apply_torque_impulse<class_RigidBody_method_apply_torque_impulse>` **(** :ref:`Vector3<class_Vector3>` impulse **)** |
  98. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`get_axis_lock<class_RigidBody_method_get_axis_lock>` **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const| |
  100. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`Array<class_Array>` | :ref:`get_colliding_bodies<class_RigidBody_method_get_colliding_bodies>` **(** **)** |const| |
  102. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`Basis<class_Basis>` | :ref:`get_inverse_inertia_tensor<class_RigidBody_method_get_inverse_inertia_tensor>` **(** **)** |
  104. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`set_axis_lock<class_RigidBody_method_set_axis_lock>` **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)** |
  106. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`set_axis_velocity<class_RigidBody_method_set_axis_velocity>` **(** :ref:`Vector3<class_Vector3>` axis_velocity **)** |
  108. +---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. .. rst-class:: classref-section-separator
  110. ----
  111. .. rst-class:: classref-descriptions-group
  112. Signals
  113. -------
  114. .. _class_RigidBody_signal_body_entered:
  115. .. rst-class:: classref-signal
  116. **body_entered** **(** :ref:`Node<class_Node>` body **)**
  117. Emitted when a collision with another :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>` occurs. Requires :ref:`contact_monitor<class_RigidBody_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody_property_contacts_reported>` to be set high enough to detect all the collisions. :ref:`GridMap<class_GridMap>`\ s are detected if the :ref:`MeshLibrary<class_MeshLibrary>` has Collision :ref:`Shape<class_Shape>`\ s.
  118. \ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>`.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_RigidBody_signal_body_exited:
  122. .. rst-class:: classref-signal
  123. **body_exited** **(** :ref:`Node<class_Node>` body **)**
  124. Emitted when the collision with another :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>` ends. Requires :ref:`contact_monitor<class_RigidBody_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody_property_contacts_reported>` to be set high enough to detect all the collisions. :ref:`GridMap<class_GridMap>`\ s are detected if the :ref:`MeshLibrary<class_MeshLibrary>` has Collision :ref:`Shape<class_Shape>`\ s.
  125. \ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>`.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_RigidBody_signal_body_shape_entered:
  129. .. rst-class:: classref-signal
  130. **body_shape_entered** **(** :ref:`RID<class_RID>` body_rid, :ref:`Node<class_Node>` body, :ref:`int<class_int>` body_shape_index, :ref:`int<class_int>` local_shape_index **)**
  131. Emitted when one of this RigidBody's :ref:`Shape<class_Shape>`\ s collides with another :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>`'s :ref:`Shape<class_Shape>`\ s. Requires :ref:`contact_monitor<class_RigidBody_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody_property_contacts_reported>` to be set high enough to detect all the collisions. :ref:`GridMap<class_GridMap>`\ s are detected if the :ref:`MeshLibrary<class_MeshLibrary>` has Collision :ref:`Shape<class_Shape>`\ s.
  132. \ ``body_rid`` the :ref:`RID<class_RID>` of the other :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`MeshLibrary<class_MeshLibrary>`'s :ref:`CollisionObject<class_CollisionObject>` used by the :ref:`PhysicsServer<class_PhysicsServer>`.
  133. \ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>`.
  134. \ ``body_shape_index`` the index of the :ref:`Shape<class_Shape>` of the other :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>` used by the :ref:`PhysicsServer<class_PhysicsServer>`. Get the :ref:`CollisionShape<class_CollisionShape>` node with ``body.shape_owner_get_owner(body_shape_index)``.
  135. \ ``local_shape_index`` the index of the :ref:`Shape<class_Shape>` of this RigidBody used by the :ref:`PhysicsServer<class_PhysicsServer>`. Get the :ref:`CollisionShape<class_CollisionShape>` node with ``self.shape_owner_get_owner(local_shape_index)``.
  136. \ **Note:** Bullet physics cannot identify the shape index when using a :ref:`ConcavePolygonShape<class_ConcavePolygonShape>`. Don't use multiple :ref:`CollisionShape<class_CollisionShape>`\ s when using a :ref:`ConcavePolygonShape<class_ConcavePolygonShape>` with Bullet physics if you need shape indices.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_RigidBody_signal_body_shape_exited:
  140. .. rst-class:: classref-signal
  141. **body_shape_exited** **(** :ref:`RID<class_RID>` body_rid, :ref:`Node<class_Node>` body, :ref:`int<class_int>` body_shape_index, :ref:`int<class_int>` local_shape_index **)**
  142. Emitted when the collision between one of this RigidBody's :ref:`Shape<class_Shape>`\ s and another :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>`'s :ref:`Shape<class_Shape>`\ s ends. Requires :ref:`contact_monitor<class_RigidBody_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody_property_contacts_reported>` to be set high enough to detect all the collisions. :ref:`GridMap<class_GridMap>`\ s are detected if the :ref:`MeshLibrary<class_MeshLibrary>` has Collision :ref:`Shape<class_Shape>`\ s.
  143. \ ``body_rid`` the :ref:`RID<class_RID>` of the other :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`MeshLibrary<class_MeshLibrary>`'s :ref:`CollisionObject<class_CollisionObject>` used by the :ref:`PhysicsServer<class_PhysicsServer>`. :ref:`GridMap<class_GridMap>`\ s are detected if the Meshes have :ref:`Shape<class_Shape>`\ s.
  144. \ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>`.
  145. \ ``body_shape_index`` the index of the :ref:`Shape<class_Shape>` of the other :ref:`PhysicsBody<class_PhysicsBody>` or :ref:`GridMap<class_GridMap>` used by the :ref:`PhysicsServer<class_PhysicsServer>`. Get the :ref:`CollisionShape<class_CollisionShape>` node with ``body.shape_owner_get_owner(body_shape_index)``.
  146. \ ``local_shape_index`` the index of the :ref:`Shape<class_Shape>` of this RigidBody used by the :ref:`PhysicsServer<class_PhysicsServer>`. Get the :ref:`CollisionShape<class_CollisionShape>` node with ``self.shape_owner_get_owner(local_shape_index)``.
  147. \ **Note:** Bullet physics cannot identify the shape index when using a :ref:`ConcavePolygonShape<class_ConcavePolygonShape>`. Don't use multiple :ref:`CollisionShape<class_CollisionShape>`\ s when using a :ref:`ConcavePolygonShape<class_ConcavePolygonShape>` with Bullet physics if you need shape indices.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_RigidBody_signal_sleeping_state_changed:
  151. .. rst-class:: classref-signal
  152. **sleeping_state_changed** **(** **)**
  153. Emitted when the physics engine changes the body's sleeping state.
  154. \ **Note:** Changing the value :ref:`sleeping<class_RigidBody_property_sleeping>` will not trigger this signal. It is only emitted if the sleeping state is changed by the physics engine or ``emit_signal("sleeping_state_changed")`` is used.
  155. .. rst-class:: classref-section-separator
  156. ----
  157. .. rst-class:: classref-descriptions-group
  158. Enumerations
  159. ------------
  160. .. _enum_RigidBody_Mode:
  161. .. rst-class:: classref-enumeration
  162. enum **Mode**:
  163. .. _class_RigidBody_constant_MODE_RIGID:
  164. .. rst-class:: classref-enumeration-constant
  165. :ref:`Mode<enum_RigidBody_Mode>` **MODE_RIGID** = ``0``
  166. Rigid body mode. This is the "natural" state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code.
  167. .. _class_RigidBody_constant_MODE_STATIC:
  168. .. rst-class:: classref-enumeration-constant
  169. :ref:`Mode<enum_RigidBody_Mode>` **MODE_STATIC** = ``1``
  170. Static mode. The body behaves like a :ref:`StaticBody<class_StaticBody>`, and can only move by user code.
  171. .. _class_RigidBody_constant_MODE_CHARACTER:
  172. .. rst-class:: classref-enumeration-constant
  173. :ref:`Mode<enum_RigidBody_Mode>` **MODE_CHARACTER** = ``2``
  174. Character body mode. This behaves like a rigid body, but can not rotate.
  175. .. _class_RigidBody_constant_MODE_KINEMATIC:
  176. .. rst-class:: classref-enumeration-constant
  177. :ref:`Mode<enum_RigidBody_Mode>` **MODE_KINEMATIC** = ``3``
  178. Kinematic body mode. The body behaves like a :ref:`KinematicBody<class_KinematicBody>`, and can only move by user code.
  179. .. rst-class:: classref-section-separator
  180. ----
  181. .. rst-class:: classref-descriptions-group
  182. Property Descriptions
  183. ---------------------
  184. .. _class_RigidBody_property_angular_damp:
  185. .. rst-class:: classref-property
  186. :ref:`float<class_float>` **angular_damp** = ``-1.0``
  187. .. rst-class:: classref-property-setget
  188. - void **set_angular_damp** **(** :ref:`float<class_float>` value **)**
  189. - :ref:`float<class_float>` **get_angular_damp** **(** **)**
  190. Damps the body's rotational forces. If this value is different from -1.0 it will be added to any angular damp derived from the world or areas.
  191. See :ref:`ProjectSettings.physics/3d/default_angular_damp<class_ProjectSettings_property_physics/3d/default_angular_damp>` for more details about damping.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_RigidBody_property_angular_velocity:
  195. .. rst-class:: classref-property
  196. :ref:`Vector3<class_Vector3>` **angular_velocity** = ``Vector3( 0, 0, 0 )``
  197. .. rst-class:: classref-property-setget
  198. - void **set_angular_velocity** **(** :ref:`Vector3<class_Vector3>` value **)**
  199. - :ref:`Vector3<class_Vector3>` **get_angular_velocity** **(** **)**
  200. The body's rotational velocity in axis-angle format. The magnitude of the vector is the rotation rate in *radians* per second.
  201. .. rst-class:: classref-item-separator
  202. ----
  203. .. _class_RigidBody_property_axis_lock_angular_x:
  204. .. rst-class:: classref-property
  205. :ref:`bool<class_bool>` **axis_lock_angular_x** = ``false``
  206. .. rst-class:: classref-property-setget
  207. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  208. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  209. Lock the body's rotation in the X axis.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_RigidBody_property_axis_lock_angular_y:
  213. .. rst-class:: classref-property
  214. :ref:`bool<class_bool>` **axis_lock_angular_y** = ``false``
  215. .. rst-class:: classref-property-setget
  216. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  217. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  218. Lock the body's rotation in the Y axis.
  219. .. rst-class:: classref-item-separator
  220. ----
  221. .. _class_RigidBody_property_axis_lock_angular_z:
  222. .. rst-class:: classref-property
  223. :ref:`bool<class_bool>` **axis_lock_angular_z** = ``false``
  224. .. rst-class:: classref-property-setget
  225. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  226. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  227. Lock the body's rotation in the Z axis.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_RigidBody_property_axis_lock_linear_x:
  231. .. rst-class:: classref-property
  232. :ref:`bool<class_bool>` **axis_lock_linear_x** = ``false``
  233. .. rst-class:: classref-property-setget
  234. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  235. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  236. Lock the body's movement in the X axis.
  237. .. rst-class:: classref-item-separator
  238. ----
  239. .. _class_RigidBody_property_axis_lock_linear_y:
  240. .. rst-class:: classref-property
  241. :ref:`bool<class_bool>` **axis_lock_linear_y** = ``false``
  242. .. rst-class:: classref-property-setget
  243. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  244. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  245. Lock the body's movement in the Y axis.
  246. .. rst-class:: classref-item-separator
  247. ----
  248. .. _class_RigidBody_property_axis_lock_linear_z:
  249. .. rst-class:: classref-property
  250. :ref:`bool<class_bool>` **axis_lock_linear_z** = ``false``
  251. .. rst-class:: classref-property-setget
  252. - void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  253. - :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  254. Lock the body's movement in the Z axis.
  255. .. rst-class:: classref-item-separator
  256. ----
  257. .. _class_RigidBody_property_bounce:
  258. .. rst-class:: classref-property
  259. :ref:`float<class_float>` **bounce**
  260. .. rst-class:: classref-property-setget
  261. - void **set_bounce** **(** :ref:`float<class_float>` value **)**
  262. - :ref:`float<class_float>` **get_bounce** **(** **)**
  263. The body's bounciness. Values range from ``0`` (no bounce) to ``1`` (full bounciness).
  264. Deprecated, use :ref:`PhysicsMaterial.bounce<class_PhysicsMaterial_property_bounce>` instead via :ref:`physics_material_override<class_RigidBody_property_physics_material_override>`.
  265. .. rst-class:: classref-item-separator
  266. ----
  267. .. _class_RigidBody_property_can_sleep:
  268. .. rst-class:: classref-property
  269. :ref:`bool<class_bool>` **can_sleep** = ``true``
  270. .. rst-class:: classref-property-setget
  271. - void **set_can_sleep** **(** :ref:`bool<class_bool>` value **)**
  272. - :ref:`bool<class_bool>` **is_able_to_sleep** **(** **)**
  273. If ``true``, the body can enter sleep mode when there is no movement. See :ref:`sleeping<class_RigidBody_property_sleeping>`.
  274. \ **Note:** A RigidBody3D will never enter sleep mode automatically if its :ref:`mode<class_RigidBody_property_mode>` is :ref:`MODE_CHARACTER<class_RigidBody_constant_MODE_CHARACTER>`. It can still be put to sleep manually by setting its :ref:`sleeping<class_RigidBody_property_sleeping>` property to ``true``.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_RigidBody_property_contact_monitor:
  278. .. rst-class:: classref-property
  279. :ref:`bool<class_bool>` **contact_monitor** = ``false``
  280. .. rst-class:: classref-property-setget
  281. - void **set_contact_monitor** **(** :ref:`bool<class_bool>` value **)**
  282. - :ref:`bool<class_bool>` **is_contact_monitor_enabled** **(** **)**
  283. If ``true``, the RigidBody will emit signals when it collides with another RigidBody. See also :ref:`contacts_reported<class_RigidBody_property_contacts_reported>`.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_RigidBody_property_contacts_reported:
  287. .. rst-class:: classref-property
  288. :ref:`int<class_int>` **contacts_reported** = ``0``
  289. .. rst-class:: classref-property-setget
  290. - void **set_max_contacts_reported** **(** :ref:`int<class_int>` value **)**
  291. - :ref:`int<class_int>` **get_max_contacts_reported** **(** **)**
  292. The maximum number of contacts that will be recorded. Requires :ref:`contact_monitor<class_RigidBody_property_contact_monitor>` to be set to ``true``.
  293. \ **Note:** The number of contacts is different from the number of collisions. Collisions between parallel edges will result in two contacts (one at each end), and collisions between parallel faces will result in four contacts (one at each corner).
  294. .. rst-class:: classref-item-separator
  295. ----
  296. .. _class_RigidBody_property_continuous_cd:
  297. .. rst-class:: classref-property
  298. :ref:`bool<class_bool>` **continuous_cd** = ``false``
  299. .. rst-class:: classref-property-setget
  300. - void **set_use_continuous_collision_detection** **(** :ref:`bool<class_bool>` value **)**
  301. - :ref:`bool<class_bool>` **is_using_continuous_collision_detection** **(** **)**
  302. If ``true``, continuous collision detection is used.
  303. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses fewer impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects.
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _class_RigidBody_property_custom_integrator:
  307. .. rst-class:: classref-property
  308. :ref:`bool<class_bool>` **custom_integrator** = ``false``
  309. .. rst-class:: classref-property-setget
  310. - void **set_use_custom_integrator** **(** :ref:`bool<class_bool>` value **)**
  311. - :ref:`bool<class_bool>` **is_using_custom_integrator** **(** **)**
  312. If ``true``, internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the :ref:`_integrate_forces<class_RigidBody_method__integrate_forces>` function, if defined.
  313. .. rst-class:: classref-item-separator
  314. ----
  315. .. _class_RigidBody_property_friction:
  316. .. rst-class:: classref-property
  317. :ref:`float<class_float>` **friction**
  318. .. rst-class:: classref-property-setget
  319. - void **set_friction** **(** :ref:`float<class_float>` value **)**
  320. - :ref:`float<class_float>` **get_friction** **(** **)**
  321. The body's friction, from 0 (frictionless) to 1 (max friction).
  322. Deprecated, use :ref:`PhysicsMaterial.friction<class_PhysicsMaterial_property_friction>` instead via :ref:`physics_material_override<class_RigidBody_property_physics_material_override>`.
  323. .. rst-class:: classref-item-separator
  324. ----
  325. .. _class_RigidBody_property_gravity_scale:
  326. .. rst-class:: classref-property
  327. :ref:`float<class_float>` **gravity_scale** = ``1.0``
  328. .. rst-class:: classref-property-setget
  329. - void **set_gravity_scale** **(** :ref:`float<class_float>` value **)**
  330. - :ref:`float<class_float>` **get_gravity_scale** **(** **)**
  331. This is multiplied by the global 3D gravity setting found in **Project > Project Settings > Physics > 3d** to produce RigidBody's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
  332. .. rst-class:: classref-item-separator
  333. ----
  334. .. _class_RigidBody_property_linear_damp:
  335. .. rst-class:: classref-property
  336. :ref:`float<class_float>` **linear_damp** = ``-1.0``
  337. .. rst-class:: classref-property-setget
  338. - void **set_linear_damp** **(** :ref:`float<class_float>` value **)**
  339. - :ref:`float<class_float>` **get_linear_damp** **(** **)**
  340. The body's linear damp. Cannot be less than -1.0. If this value is different from -1.0 it will be added to any linear damp derived from the world or areas.
  341. See :ref:`ProjectSettings.physics/3d/default_linear_damp<class_ProjectSettings_property_physics/3d/default_linear_damp>` for more details about damping.
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_RigidBody_property_linear_velocity:
  345. .. rst-class:: classref-property
  346. :ref:`Vector3<class_Vector3>` **linear_velocity** = ``Vector3( 0, 0, 0 )``
  347. .. rst-class:: classref-property-setget
  348. - void **set_linear_velocity** **(** :ref:`Vector3<class_Vector3>` value **)**
  349. - :ref:`Vector3<class_Vector3>` **get_linear_velocity** **(** **)**
  350. The body's linear velocity in units per second. Can be used sporadically, but **don't set this every frame**, because physics may run in another thread and runs at a different granularity. Use :ref:`_integrate_forces<class_RigidBody_method__integrate_forces>` as your process loop for precise control of the body state.
  351. .. rst-class:: classref-item-separator
  352. ----
  353. .. _class_RigidBody_property_mass:
  354. .. rst-class:: classref-property
  355. :ref:`float<class_float>` **mass** = ``1.0``
  356. .. rst-class:: classref-property-setget
  357. - void **set_mass** **(** :ref:`float<class_float>` value **)**
  358. - :ref:`float<class_float>` **get_mass** **(** **)**
  359. The body's mass.
  360. .. rst-class:: classref-item-separator
  361. ----
  362. .. _class_RigidBody_property_mode:
  363. .. rst-class:: classref-property
  364. :ref:`Mode<enum_RigidBody_Mode>` **mode** = ``0``
  365. .. rst-class:: classref-property-setget
  366. - void **set_mode** **(** :ref:`Mode<enum_RigidBody_Mode>` value **)**
  367. - :ref:`Mode<enum_RigidBody_Mode>` **get_mode** **(** **)**
  368. The body mode. See :ref:`Mode<enum_RigidBody_Mode>` for possible values.
  369. .. rst-class:: classref-item-separator
  370. ----
  371. .. _class_RigidBody_property_physics_material_override:
  372. .. rst-class:: classref-property
  373. :ref:`PhysicsMaterial<class_PhysicsMaterial>` **physics_material_override**
  374. .. rst-class:: classref-property-setget
  375. - void **set_physics_material_override** **(** :ref:`PhysicsMaterial<class_PhysicsMaterial>` value **)**
  376. - :ref:`PhysicsMaterial<class_PhysicsMaterial>` **get_physics_material_override** **(** **)**
  377. The physics material override for the body.
  378. If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_RigidBody_property_sleeping:
  382. .. rst-class:: classref-property
  383. :ref:`bool<class_bool>` **sleeping** = ``false``
  384. .. rst-class:: classref-property-setget
  385. - void **set_sleeping** **(** :ref:`bool<class_bool>` value **)**
  386. - :ref:`bool<class_bool>` **is_sleeping** **(** **)**
  387. If ``true``, the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using the :ref:`apply_impulse<class_RigidBody_method_apply_impulse>` or :ref:`add_force<class_RigidBody_method_add_force>` methods.
  388. .. rst-class:: classref-item-separator
  389. ----
  390. .. _class_RigidBody_property_weight:
  391. .. rst-class:: classref-property
  392. :ref:`float<class_float>` **weight** = ``9.8``
  393. .. rst-class:: classref-property-setget
  394. - void **set_weight** **(** :ref:`float<class_float>` value **)**
  395. - :ref:`float<class_float>` **get_weight** **(** **)**
  396. The body's weight based on its mass and the global 3D gravity. Global values are set in **Project > Project Settings > Physics > 3d**.
  397. .. rst-class:: classref-section-separator
  398. ----
  399. .. rst-class:: classref-descriptions-group
  400. Method Descriptions
  401. -------------------
  402. .. _class_RigidBody_method__integrate_forces:
  403. .. rst-class:: classref-method
  404. void **_integrate_forces** **(** :ref:`PhysicsDirectBodyState<class_PhysicsDirectBodyState>` state **)** |virtual|
  405. Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it works in addition to the usual physics behavior, but the :ref:`custom_integrator<class_RigidBody_property_custom_integrator>` property allows you to disable the default behavior and do fully custom force integration for a body.
  406. .. rst-class:: classref-item-separator
  407. ----
  408. .. _class_RigidBody_method_add_central_force:
  409. .. rst-class:: classref-method
  410. void **add_central_force** **(** :ref:`Vector3<class_Vector3>` force **)**
  411. Adds a constant directional force (i.e. acceleration) without affecting rotation.
  412. This is equivalent to ``add_force(force, Vector3(0,0,0))``.
  413. .. rst-class:: classref-item-separator
  414. ----
  415. .. _class_RigidBody_method_add_force:
  416. .. rst-class:: classref-method
  417. void **add_force** **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position **)**
  418. Adds a constant directional force (i.e. acceleration).
  419. The position uses the rotation of the global coordinate system, but is centered at the object's origin.
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_RigidBody_method_add_torque:
  423. .. rst-class:: classref-method
  424. void **add_torque** **(** :ref:`Vector3<class_Vector3>` torque **)**
  425. Adds a constant rotational force (i.e. a motor) without affecting position.
  426. .. rst-class:: classref-item-separator
  427. ----
  428. .. _class_RigidBody_method_apply_central_impulse:
  429. .. rst-class:: classref-method
  430. void **apply_central_impulse** **(** :ref:`Vector3<class_Vector3>` impulse **)**
  431. Applies a directional impulse without affecting rotation.
  432. This is equivalent to ``apply_impulse(Vector3(0,0,0), impulse)``.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_RigidBody_method_apply_impulse:
  436. .. rst-class:: classref-method
  437. void **apply_impulse** **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` impulse **)**
  438. Applies a positioned impulse to the body. An impulse is time independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin.
  439. .. rst-class:: classref-item-separator
  440. ----
  441. .. _class_RigidBody_method_apply_torque_impulse:
  442. .. rst-class:: classref-method
  443. void **apply_torque_impulse** **(** :ref:`Vector3<class_Vector3>` impulse **)**
  444. Applies a torque impulse which will be affected by the body mass and shape. This will rotate the body around the ``impulse`` vector passed.
  445. .. rst-class:: classref-item-separator
  446. ----
  447. .. _class_RigidBody_method_get_axis_lock:
  448. .. rst-class:: classref-method
  449. :ref:`bool<class_bool>` **get_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis **)** |const|
  450. Returns ``true`` if the specified linear or rotational axis is locked.
  451. .. rst-class:: classref-item-separator
  452. ----
  453. .. _class_RigidBody_method_get_colliding_bodies:
  454. .. rst-class:: classref-method
  455. :ref:`Array<class_Array>` **get_colliding_bodies** **(** **)** |const|
  456. Returns a list of the bodies colliding with this one. Requires :ref:`contact_monitor<class_RigidBody_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidBody_property_contacts_reported>` to be set high enough to detect all the collisions.
  457. \ **Note:** The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.
  458. .. rst-class:: classref-item-separator
  459. ----
  460. .. _class_RigidBody_method_get_inverse_inertia_tensor:
  461. .. rst-class:: classref-method
  462. :ref:`Basis<class_Basis>` **get_inverse_inertia_tensor** **(** **)**
  463. Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the RigidBody.
  464. .. rst-class:: classref-item-separator
  465. ----
  466. .. _class_RigidBody_method_set_axis_lock:
  467. .. rst-class:: classref-method
  468. void **set_axis_lock** **(** :ref:`BodyAxis<enum_PhysicsServer_BodyAxis>` axis, :ref:`bool<class_bool>` lock **)**
  469. Locks the specified linear or rotational axis.
  470. .. rst-class:: classref-item-separator
  471. ----
  472. .. _class_RigidBody_method_set_axis_velocity:
  473. .. rst-class:: classref-method
  474. void **set_axis_velocity** **(** :ref:`Vector3<class_Vector3>` axis_velocity **)**
  475. Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
  476. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  477. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  478. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  479. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`