class_rigiddynamicbody3d.rst 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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/RigidDynamicBody3D.xml.
  6. .. _class_RigidDynamicBody3D:
  7. RigidDynamicBody3D
  8. ==================
  9. **Inherits:** :ref:`PhysicsBody3D<class_PhysicsBody3D>` **<** :ref:`CollisionObject3D<class_CollisionObject3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`VehicleBody3D<class_VehicleBody3D>`
  11. Physics Body which is moved by 3D physics simulation. Useful for objects that have gravity and can be pushed by other objects.
  12. Description
  13. -----------
  14. This is the node that implements full 3D physics. This means that you do not control a RigidDynamicBody3D directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
  15. You can switch the body's behavior using :ref:`lock_rotation<class_RigidDynamicBody3D_property_lock_rotation>`, :ref:`freeze<class_RigidDynamicBody3D_property_freeze>`, and :ref:`freeze_mode<class_RigidDynamicBody3D_property_freeze_mode>`.
  16. \ **Note:** Don't change a RigidDynamicBody3D'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_RigidDynamicBody3D_method__integrate_forces>`, which allows you to directly access the physics state.
  17. If you need to override the default physics behavior, you can write a custom force integration function. See :ref:`custom_integrator<class_RigidDynamicBody3D_property_custom_integrator>`.
  18. Tutorials
  19. ---------
  20. - :doc:`Physics introduction <../tutorials/physics/physics_introduction>`
  21. - `3D Truck Town Demo <https://godotengine.org/asset-library/asset/524>`__
  22. - `3D Physics Tests Demo <https://godotengine.org/asset-library/asset/675>`__
  23. Properties
  24. ----------
  25. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  26. | :ref:`float<class_float>` | :ref:`angular_damp<class_RigidDynamicBody3D_property_angular_damp>` | ``0.0`` |
  27. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  28. | :ref:`DampMode<enum_RigidDynamicBody3D_DampMode>` | :ref:`angular_damp_mode<class_RigidDynamicBody3D_property_angular_damp_mode>` | ``0`` |
  29. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  30. | :ref:`Vector3<class_Vector3>` | :ref:`angular_velocity<class_RigidDynamicBody3D_property_angular_velocity>` | ``Vector3(0, 0, 0)`` |
  31. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  32. | :ref:`bool<class_bool>` | :ref:`can_sleep<class_RigidDynamicBody3D_property_can_sleep>` | ``true`` |
  33. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  34. | :ref:`Vector3<class_Vector3>` | :ref:`center_of_mass<class_RigidDynamicBody3D_property_center_of_mass>` | ``Vector3(0, 0, 0)`` |
  35. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  36. | :ref:`CenterOfMassMode<enum_RigidDynamicBody3D_CenterOfMassMode>` | :ref:`center_of_mass_mode<class_RigidDynamicBody3D_property_center_of_mass_mode>` | ``0`` |
  37. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  38. | :ref:`Vector3<class_Vector3>` | :ref:`constant_force<class_RigidDynamicBody3D_property_constant_force>` | ``Vector3(0, 0, 0)`` |
  39. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  40. | :ref:`Vector3<class_Vector3>` | :ref:`constant_torque<class_RigidDynamicBody3D_property_constant_torque>` | ``Vector3(0, 0, 0)`` |
  41. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  42. | :ref:`bool<class_bool>` | :ref:`contact_monitor<class_RigidDynamicBody3D_property_contact_monitor>` | ``false`` |
  43. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  44. | :ref:`int<class_int>` | :ref:`contacts_reported<class_RigidDynamicBody3D_property_contacts_reported>` | ``0`` |
  45. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  46. | :ref:`bool<class_bool>` | :ref:`continuous_cd<class_RigidDynamicBody3D_property_continuous_cd>` | ``false`` |
  47. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  48. | :ref:`bool<class_bool>` | :ref:`custom_integrator<class_RigidDynamicBody3D_property_custom_integrator>` | ``false`` |
  49. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  50. | :ref:`bool<class_bool>` | :ref:`freeze<class_RigidDynamicBody3D_property_freeze>` | ``false`` |
  51. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  52. | :ref:`FreezeMode<enum_RigidDynamicBody3D_FreezeMode>` | :ref:`freeze_mode<class_RigidDynamicBody3D_property_freeze_mode>` | ``0`` |
  53. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  54. | :ref:`float<class_float>` | :ref:`gravity_scale<class_RigidDynamicBody3D_property_gravity_scale>` | ``1.0`` |
  55. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  56. | :ref:`Vector3<class_Vector3>` | :ref:`inertia<class_RigidDynamicBody3D_property_inertia>` | ``Vector3(0, 0, 0)`` |
  57. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  58. | :ref:`float<class_float>` | :ref:`linear_damp<class_RigidDynamicBody3D_property_linear_damp>` | ``0.0`` |
  59. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  60. | :ref:`DampMode<enum_RigidDynamicBody3D_DampMode>` | :ref:`linear_damp_mode<class_RigidDynamicBody3D_property_linear_damp_mode>` | ``0`` |
  61. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  62. | :ref:`Vector3<class_Vector3>` | :ref:`linear_velocity<class_RigidDynamicBody3D_property_linear_velocity>` | ``Vector3(0, 0, 0)`` |
  63. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  64. | :ref:`bool<class_bool>` | :ref:`lock_rotation<class_RigidDynamicBody3D_property_lock_rotation>` | ``false`` |
  65. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  66. | :ref:`float<class_float>` | :ref:`mass<class_RigidDynamicBody3D_property_mass>` | ``1.0`` |
  67. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  68. | :ref:`PhysicsMaterial<class_PhysicsMaterial>` | :ref:`physics_material_override<class_RigidDynamicBody3D_property_physics_material_override>` | |
  69. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  70. | :ref:`bool<class_bool>` | :ref:`sleeping<class_RigidDynamicBody3D_property_sleeping>` | ``false`` |
  71. +-------------------------------------------------------------------+-----------------------------------------------------------------------------------------------+----------------------+
  72. Methods
  73. -------
  74. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`_integrate_forces<class_RigidDynamicBody3D_method__integrate_forces>` **(** :ref:`PhysicsDirectBodyState3D<class_PhysicsDirectBodyState3D>` state **)** |virtual| |
  76. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`add_constant_central_force<class_RigidDynamicBody3D_method_add_constant_central_force>` **(** :ref:`Vector3<class_Vector3>` force **)** |
  78. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`add_constant_force<class_RigidDynamicBody3D_method_add_constant_force>` **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position=Vector3(0, 0, 0) **)** |
  80. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`add_constant_torque<class_RigidDynamicBody3D_method_add_constant_torque>` **(** :ref:`Vector3<class_Vector3>` torque **)** |
  82. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`apply_central_force<class_RigidDynamicBody3D_method_apply_central_force>` **(** :ref:`Vector3<class_Vector3>` force **)** |
  84. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`apply_central_impulse<class_RigidDynamicBody3D_method_apply_central_impulse>` **(** :ref:`Vector3<class_Vector3>` impulse **)** |
  86. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`apply_force<class_RigidDynamicBody3D_method_apply_force>` **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position=Vector3(0, 0, 0) **)** |
  88. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`apply_impulse<class_RigidDynamicBody3D_method_apply_impulse>` **(** :ref:`Vector3<class_Vector3>` impulse, :ref:`Vector3<class_Vector3>` position=Vector3(0, 0, 0) **)** |
  90. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`apply_torque<class_RigidDynamicBody3D_method_apply_torque>` **(** :ref:`Vector3<class_Vector3>` torque **)** |
  92. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`apply_torque_impulse<class_RigidDynamicBody3D_method_apply_torque_impulse>` **(** :ref:`Vector3<class_Vector3>` impulse **)** |
  94. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`Array<class_Array>` | :ref:`get_colliding_bodies<class_RigidDynamicBody3D_method_get_colliding_bodies>` **(** **)** |const| |
  96. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`Basis<class_Basis>` | :ref:`get_inverse_inertia_tensor<class_RigidDynamicBody3D_method_get_inverse_inertia_tensor>` **(** **)** |const| |
  98. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`set_axis_velocity<class_RigidDynamicBody3D_method_set_axis_velocity>` **(** :ref:`Vector3<class_Vector3>` axis_velocity **)** |
  100. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. Signals
  102. -------
  103. .. _class_RigidDynamicBody3D_signal_body_entered:
  104. - **body_entered** **(** :ref:`Node<class_Node>` body **)**
  105. Emitted when a collision with another :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>` occurs. Requires :ref:`contact_monitor<class_RigidDynamicBody3D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidDynamicBody3D_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:`Shape3D<class_Shape3D>`\ s.
  106. \ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>`.
  107. ----
  108. .. _class_RigidDynamicBody3D_signal_body_exited:
  109. - **body_exited** **(** :ref:`Node<class_Node>` body **)**
  110. Emitted when the collision with another :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>` ends. Requires :ref:`contact_monitor<class_RigidDynamicBody3D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidDynamicBody3D_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:`Shape3D<class_Shape3D>`\ s.
  111. \ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>`.
  112. ----
  113. .. _class_RigidDynamicBody3D_signal_body_shape_entered:
  114. - **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 **)**
  115. Emitted when one of this RigidDynamicBody3D's :ref:`Shape3D<class_Shape3D>`\ s collides with another :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>`'s :ref:`Shape3D<class_Shape3D>`\ s. Requires :ref:`contact_monitor<class_RigidDynamicBody3D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidDynamicBody3D_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:`Shape3D<class_Shape3D>`\ s.
  116. \ ``body_rid`` the :ref:`RID<class_RID>` of the other :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`MeshLibrary<class_MeshLibrary>`'s :ref:`CollisionObject3D<class_CollisionObject3D>` used by the :ref:`PhysicsServer3D<class_PhysicsServer3D>`.
  117. \ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>`.
  118. \ ``body_shape_index`` the index of the :ref:`Shape3D<class_Shape3D>` of the other :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>` used by the :ref:`PhysicsServer3D<class_PhysicsServer3D>`. Get the :ref:`CollisionShape3D<class_CollisionShape3D>` node with ``body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))``.
  119. \ ``local_shape_index`` the index of the :ref:`Shape3D<class_Shape3D>` of this RigidDynamicBody3D used by the :ref:`PhysicsServer3D<class_PhysicsServer3D>`. Get the :ref:`CollisionShape3D<class_CollisionShape3D>` node with ``self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))``.
  120. ----
  121. .. _class_RigidDynamicBody3D_signal_body_shape_exited:
  122. - **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 **)**
  123. Emitted when the collision between one of this RigidDynamicBody3D's :ref:`Shape3D<class_Shape3D>`\ s and another :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>`'s :ref:`Shape3D<class_Shape3D>`\ s ends. Requires :ref:`contact_monitor<class_RigidDynamicBody3D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidDynamicBody3D_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:`Shape3D<class_Shape3D>`\ s.
  124. \ ``body_rid`` the :ref:`RID<class_RID>` of the other :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`MeshLibrary<class_MeshLibrary>`'s :ref:`CollisionObject3D<class_CollisionObject3D>` used by the :ref:`PhysicsServer3D<class_PhysicsServer3D>`. :ref:`GridMap<class_GridMap>`\ s are detected if the Meshes have :ref:`Shape3D<class_Shape3D>`\ s.
  125. \ ``body`` the :ref:`Node<class_Node>`, if it exists in the tree, of the other :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>`.
  126. \ ``body_shape_index`` the index of the :ref:`Shape3D<class_Shape3D>` of the other :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`GridMap<class_GridMap>` used by the :ref:`PhysicsServer3D<class_PhysicsServer3D>`. Get the :ref:`CollisionShape3D<class_CollisionShape3D>` node with ``body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))``.
  127. \ ``local_shape_index`` the index of the :ref:`Shape3D<class_Shape3D>` of this RigidDynamicBody3D used by the :ref:`PhysicsServer3D<class_PhysicsServer3D>`. Get the :ref:`CollisionShape3D<class_CollisionShape3D>` node with ``self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))``.
  128. ----
  129. .. _class_RigidDynamicBody3D_signal_sleeping_state_changed:
  130. - **sleeping_state_changed** **(** **)**
  131. Emitted when the physics engine changes the body's sleeping state.
  132. \ **Note:** Changing the value :ref:`sleeping<class_RigidDynamicBody3D_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.
  133. Enumerations
  134. ------------
  135. .. _enum_RigidDynamicBody3D_FreezeMode:
  136. .. _class_RigidDynamicBody3D_constant_FREEZE_MODE_STATIC:
  137. .. _class_RigidDynamicBody3D_constant_FREEZE_MODE_KINEMATIC:
  138. enum **FreezeMode**:
  139. - **FREEZE_MODE_STATIC** = **0** --- Static body freeze mode (default). The body is not affected by gravity and forces. It can be only moved by user code and doesn't collide with other bodies along its path.
  140. - **FREEZE_MODE_KINEMATIC** = **1** --- Kinematic body freeze mode. Similar to :ref:`FREEZE_MODE_STATIC<class_RigidDynamicBody3D_constant_FREEZE_MODE_STATIC>`, but collides with other bodies along its path when moved. Useful for a frozen body that needs to be animated.
  141. ----
  142. .. _enum_RigidDynamicBody3D_CenterOfMassMode:
  143. .. _class_RigidDynamicBody3D_constant_CENTER_OF_MASS_MODE_AUTO:
  144. .. _class_RigidDynamicBody3D_constant_CENTER_OF_MASS_MODE_CUSTOM:
  145. enum **CenterOfMassMode**:
  146. - **CENTER_OF_MASS_MODE_AUTO** = **0** --- In this mode, the body's center of mass is calculated automatically based on its shapes.
  147. - **CENTER_OF_MASS_MODE_CUSTOM** = **1** --- In this mode, the body's center of mass is set through :ref:`center_of_mass<class_RigidDynamicBody3D_property_center_of_mass>`. Defaults to the body's origin position.
  148. ----
  149. .. _enum_RigidDynamicBody3D_DampMode:
  150. .. _class_RigidDynamicBody3D_constant_DAMP_MODE_COMBINE:
  151. .. _class_RigidDynamicBody3D_constant_DAMP_MODE_REPLACE:
  152. enum **DampMode**:
  153. - **DAMP_MODE_COMBINE** = **0** --- In this mode, the body's damping value is added to any value set in areas or the default value.
  154. - **DAMP_MODE_REPLACE** = **1** --- In this mode, the body's damping value replaces any value set in areas or the default value.
  155. Property Descriptions
  156. ---------------------
  157. .. _class_RigidDynamicBody3D_property_angular_damp:
  158. - :ref:`float<class_float>` **angular_damp**
  159. +-----------+-------------------------+
  160. | *Default* | ``0.0`` |
  161. +-----------+-------------------------+
  162. | *Setter* | set_angular_damp(value) |
  163. +-----------+-------------------------+
  164. | *Getter* | get_angular_damp() |
  165. +-----------+-------------------------+
  166. Damps the body's rotation. By default, the body will use the **Default Angular Damp** in **Project > Project Settings > Physics > 3d** or any value override set by an :ref:`Area3D<class_Area3D>` the body is in. Depending on :ref:`angular_damp_mode<class_RigidDynamicBody3D_property_angular_damp_mode>`, you can set :ref:`angular_damp<class_RigidDynamicBody3D_property_angular_damp>` to be added to or to replace the body's damping value.
  167. See :ref:`ProjectSettings.physics/3d/default_angular_damp<class_ProjectSettings_property_physics/3d/default_angular_damp>` for more details about damping.
  168. ----
  169. .. _class_RigidDynamicBody3D_property_angular_damp_mode:
  170. - :ref:`DampMode<enum_RigidDynamicBody3D_DampMode>` **angular_damp_mode**
  171. +-----------+------------------------------+
  172. | *Default* | ``0`` |
  173. +-----------+------------------------------+
  174. | *Setter* | set_angular_damp_mode(value) |
  175. +-----------+------------------------------+
  176. | *Getter* | get_angular_damp_mode() |
  177. +-----------+------------------------------+
  178. Defines how :ref:`angular_damp<class_RigidDynamicBody3D_property_angular_damp>` is applied. See :ref:`DampMode<enum_RigidDynamicBody3D_DampMode>` for possible values.
  179. ----
  180. .. _class_RigidDynamicBody3D_property_angular_velocity:
  181. - :ref:`Vector3<class_Vector3>` **angular_velocity**
  182. +-----------+-----------------------------+
  183. | *Default* | ``Vector3(0, 0, 0)`` |
  184. +-----------+-----------------------------+
  185. | *Setter* | set_angular_velocity(value) |
  186. +-----------+-----------------------------+
  187. | *Getter* | get_angular_velocity() |
  188. +-----------+-----------------------------+
  189. The RigidDynamicBody3D's rotational velocity in *radians* per second.
  190. ----
  191. .. _class_RigidDynamicBody3D_property_can_sleep:
  192. - :ref:`bool<class_bool>` **can_sleep**
  193. +-----------+----------------------+
  194. | *Default* | ``true`` |
  195. +-----------+----------------------+
  196. | *Setter* | set_can_sleep(value) |
  197. +-----------+----------------------+
  198. | *Getter* | is_able_to_sleep() |
  199. +-----------+----------------------+
  200. If ``true``, the body can enter sleep mode when there is no movement. See :ref:`sleeping<class_RigidDynamicBody3D_property_sleeping>`.
  201. ----
  202. .. _class_RigidDynamicBody3D_property_center_of_mass:
  203. - :ref:`Vector3<class_Vector3>` **center_of_mass**
  204. +-----------+---------------------------+
  205. | *Default* | ``Vector3(0, 0, 0)`` |
  206. +-----------+---------------------------+
  207. | *Setter* | set_center_of_mass(value) |
  208. +-----------+---------------------------+
  209. | *Getter* | get_center_of_mass() |
  210. +-----------+---------------------------+
  211. The body's custom center of mass, relative to the body's origin position, when :ref:`center_of_mass_mode<class_RigidDynamicBody3D_property_center_of_mass_mode>` is set to :ref:`CENTER_OF_MASS_MODE_CUSTOM<class_RigidDynamicBody3D_constant_CENTER_OF_MASS_MODE_CUSTOM>`. This is the balanced point of the body, where applied forces only cause linear acceleration. Applying forces outside of the center of mass causes angular acceleration.
  212. When :ref:`center_of_mass_mode<class_RigidDynamicBody3D_property_center_of_mass_mode>` is set to :ref:`CENTER_OF_MASS_MODE_AUTO<class_RigidDynamicBody3D_constant_CENTER_OF_MASS_MODE_AUTO>` (default value), the center of mass is automatically computed.
  213. ----
  214. .. _class_RigidDynamicBody3D_property_center_of_mass_mode:
  215. - :ref:`CenterOfMassMode<enum_RigidDynamicBody3D_CenterOfMassMode>` **center_of_mass_mode**
  216. +-----------+--------------------------------+
  217. | *Default* | ``0`` |
  218. +-----------+--------------------------------+
  219. | *Setter* | set_center_of_mass_mode(value) |
  220. +-----------+--------------------------------+
  221. | *Getter* | get_center_of_mass_mode() |
  222. +-----------+--------------------------------+
  223. Defines the way the body's center of mass is set. See :ref:`CenterOfMassMode<enum_RigidDynamicBody3D_CenterOfMassMode>` for possible values.
  224. ----
  225. .. _class_RigidDynamicBody3D_property_constant_force:
  226. - :ref:`Vector3<class_Vector3>` **constant_force**
  227. +-----------+---------------------------+
  228. | *Default* | ``Vector3(0, 0, 0)`` |
  229. +-----------+---------------------------+
  230. | *Setter* | set_constant_force(value) |
  231. +-----------+---------------------------+
  232. | *Getter* | get_constant_force() |
  233. +-----------+---------------------------+
  234. The body's total constant positional forces applied during each physics update.
  235. See :ref:`add_constant_force<class_RigidDynamicBody3D_method_add_constant_force>` and :ref:`add_constant_central_force<class_RigidDynamicBody3D_method_add_constant_central_force>`.
  236. ----
  237. .. _class_RigidDynamicBody3D_property_constant_torque:
  238. - :ref:`Vector3<class_Vector3>` **constant_torque**
  239. +-----------+----------------------------+
  240. | *Default* | ``Vector3(0, 0, 0)`` |
  241. +-----------+----------------------------+
  242. | *Setter* | set_constant_torque(value) |
  243. +-----------+----------------------------+
  244. | *Getter* | get_constant_torque() |
  245. +-----------+----------------------------+
  246. The body's total constant rotational forces applied during each physics update.
  247. See :ref:`add_constant_torque<class_RigidDynamicBody3D_method_add_constant_torque>`.
  248. ----
  249. .. _class_RigidDynamicBody3D_property_contact_monitor:
  250. - :ref:`bool<class_bool>` **contact_monitor**
  251. +-----------+------------------------------+
  252. | *Default* | ``false`` |
  253. +-----------+------------------------------+
  254. | *Setter* | set_contact_monitor(value) |
  255. +-----------+------------------------------+
  256. | *Getter* | is_contact_monitor_enabled() |
  257. +-----------+------------------------------+
  258. If ``true``, the RigidDynamicBody3D will emit signals when it collides with another RigidDynamicBody3D. See also :ref:`contacts_reported<class_RigidDynamicBody3D_property_contacts_reported>`.
  259. ----
  260. .. _class_RigidDynamicBody3D_property_contacts_reported:
  261. - :ref:`int<class_int>` **contacts_reported**
  262. +-----------+----------------------------------+
  263. | *Default* | ``0`` |
  264. +-----------+----------------------------------+
  265. | *Setter* | set_max_contacts_reported(value) |
  266. +-----------+----------------------------------+
  267. | *Getter* | get_max_contacts_reported() |
  268. +-----------+----------------------------------+
  269. The maximum number of contacts that will be recorded. Requires :ref:`contact_monitor<class_RigidDynamicBody3D_property_contact_monitor>` to be set to ``true``.
  270. \ **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).
  271. ----
  272. .. _class_RigidDynamicBody3D_property_continuous_cd:
  273. - :ref:`bool<class_bool>` **continuous_cd**
  274. +-----------+-----------------------------------------------+
  275. | *Default* | ``false`` |
  276. +-----------+-----------------------------------------------+
  277. | *Setter* | set_use_continuous_collision_detection(value) |
  278. +-----------+-----------------------------------------------+
  279. | *Getter* | is_using_continuous_collision_detection() |
  280. +-----------+-----------------------------------------------+
  281. If ``true``, continuous collision detection is used.
  282. 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.
  283. ----
  284. .. _class_RigidDynamicBody3D_property_custom_integrator:
  285. - :ref:`bool<class_bool>` **custom_integrator**
  286. +-----------+----------------------------------+
  287. | *Default* | ``false`` |
  288. +-----------+----------------------------------+
  289. | *Setter* | set_use_custom_integrator(value) |
  290. +-----------+----------------------------------+
  291. | *Getter* | is_using_custom_integrator() |
  292. +-----------+----------------------------------+
  293. 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_RigidDynamicBody3D_method__integrate_forces>` function, if defined.
  294. ----
  295. .. _class_RigidDynamicBody3D_property_freeze:
  296. - :ref:`bool<class_bool>` **freeze**
  297. +-----------+---------------------------+
  298. | *Default* | ``false`` |
  299. +-----------+---------------------------+
  300. | *Setter* | set_freeze_enabled(value) |
  301. +-----------+---------------------------+
  302. | *Getter* | is_freeze_enabled() |
  303. +-----------+---------------------------+
  304. If ``true``, the body is frozen. Gravity and forces are not applied anymore.
  305. See :ref:`freeze_mode<class_RigidDynamicBody3D_property_freeze_mode>` to set the body's behavior when frozen.
  306. For a body that is always frozen, use :ref:`StaticBody3D<class_StaticBody3D>` or :ref:`AnimatableBody3D<class_AnimatableBody3D>` instead.
  307. ----
  308. .. _class_RigidDynamicBody3D_property_freeze_mode:
  309. - :ref:`FreezeMode<enum_RigidDynamicBody3D_FreezeMode>` **freeze_mode**
  310. +-----------+------------------------+
  311. | *Default* | ``0`` |
  312. +-----------+------------------------+
  313. | *Setter* | set_freeze_mode(value) |
  314. +-----------+------------------------+
  315. | *Getter* | get_freeze_mode() |
  316. +-----------+------------------------+
  317. The body's freeze mode. Can be used to set the body's behavior when :ref:`freeze<class_RigidDynamicBody3D_property_freeze>` is enabled. See :ref:`FreezeMode<enum_RigidDynamicBody3D_FreezeMode>` for possible values.
  318. For a body that is always frozen, use :ref:`StaticBody3D<class_StaticBody3D>` or :ref:`AnimatableBody3D<class_AnimatableBody3D>` instead.
  319. ----
  320. .. _class_RigidDynamicBody3D_property_gravity_scale:
  321. - :ref:`float<class_float>` **gravity_scale**
  322. +-----------+--------------------------+
  323. | *Default* | ``1.0`` |
  324. +-----------+--------------------------+
  325. | *Setter* | set_gravity_scale(value) |
  326. +-----------+--------------------------+
  327. | *Getter* | get_gravity_scale() |
  328. +-----------+--------------------------+
  329. This is multiplied by the global 3D gravity setting found in **Project > Project Settings > Physics > 3d** to produce RigidDynamicBody3D'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.
  330. ----
  331. .. _class_RigidDynamicBody3D_property_inertia:
  332. - :ref:`Vector3<class_Vector3>` **inertia**
  333. +-----------+----------------------+
  334. | *Default* | ``Vector3(0, 0, 0)`` |
  335. +-----------+----------------------+
  336. | *Setter* | set_inertia(value) |
  337. +-----------+----------------------+
  338. | *Getter* | get_inertia() |
  339. +-----------+----------------------+
  340. The body's moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body on each axis. The moment of inertia is usually computed automatically from the mass and the shapes, but this property allows you to set a custom value.
  341. If set to ``Vector3.ZERO``, inertia is automatically computed (default value).
  342. ----
  343. .. _class_RigidDynamicBody3D_property_linear_damp:
  344. - :ref:`float<class_float>` **linear_damp**
  345. +-----------+------------------------+
  346. | *Default* | ``0.0`` |
  347. +-----------+------------------------+
  348. | *Setter* | set_linear_damp(value) |
  349. +-----------+------------------------+
  350. | *Getter* | get_linear_damp() |
  351. +-----------+------------------------+
  352. Damps the body's movement. By default, the body will use the **Default Linear Damp** in **Project > Project Settings > Physics > 3d** or any value override set by an :ref:`Area3D<class_Area3D>` the body is in. Depending on :ref:`linear_damp_mode<class_RigidDynamicBody3D_property_linear_damp_mode>`, you can set :ref:`linear_damp<class_RigidDynamicBody3D_property_linear_damp>` to be added to or to replace the body's damping value.
  353. See :ref:`ProjectSettings.physics/3d/default_linear_damp<class_ProjectSettings_property_physics/3d/default_linear_damp>` for more details about damping.
  354. ----
  355. .. _class_RigidDynamicBody3D_property_linear_damp_mode:
  356. - :ref:`DampMode<enum_RigidDynamicBody3D_DampMode>` **linear_damp_mode**
  357. +-----------+-----------------------------+
  358. | *Default* | ``0`` |
  359. +-----------+-----------------------------+
  360. | *Setter* | set_linear_damp_mode(value) |
  361. +-----------+-----------------------------+
  362. | *Getter* | get_linear_damp_mode() |
  363. +-----------+-----------------------------+
  364. Defines how :ref:`linear_damp<class_RigidDynamicBody3D_property_linear_damp>` is applied. See :ref:`DampMode<enum_RigidDynamicBody3D_DampMode>` for possible values.
  365. ----
  366. .. _class_RigidDynamicBody3D_property_linear_velocity:
  367. - :ref:`Vector3<class_Vector3>` **linear_velocity**
  368. +-----------+----------------------------+
  369. | *Default* | ``Vector3(0, 0, 0)`` |
  370. +-----------+----------------------------+
  371. | *Setter* | set_linear_velocity(value) |
  372. +-----------+----------------------------+
  373. | *Getter* | get_linear_velocity() |
  374. +-----------+----------------------------+
  375. 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_RigidDynamicBody3D_method__integrate_forces>` as your process loop for precise control of the body state.
  376. ----
  377. .. _class_RigidDynamicBody3D_property_lock_rotation:
  378. - :ref:`bool<class_bool>` **lock_rotation**
  379. +-----------+----------------------------------+
  380. | *Default* | ``false`` |
  381. +-----------+----------------------------------+
  382. | *Setter* | set_lock_rotation_enabled(value) |
  383. +-----------+----------------------------------+
  384. | *Getter* | is_lock_rotation_enabled() |
  385. +-----------+----------------------------------+
  386. If ``true``, the body cannot rotate. Gravity and forces only apply linear movement.
  387. ----
  388. .. _class_RigidDynamicBody3D_property_mass:
  389. - :ref:`float<class_float>` **mass**
  390. +-----------+-----------------+
  391. | *Default* | ``1.0`` |
  392. +-----------+-----------------+
  393. | *Setter* | set_mass(value) |
  394. +-----------+-----------------+
  395. | *Getter* | get_mass() |
  396. +-----------+-----------------+
  397. The body's mass.
  398. ----
  399. .. _class_RigidDynamicBody3D_property_physics_material_override:
  400. - :ref:`PhysicsMaterial<class_PhysicsMaterial>` **physics_material_override**
  401. +----------+--------------------------------------+
  402. | *Setter* | set_physics_material_override(value) |
  403. +----------+--------------------------------------+
  404. | *Getter* | get_physics_material_override() |
  405. +----------+--------------------------------------+
  406. The physics material override for the body.
  407. If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
  408. ----
  409. .. _class_RigidDynamicBody3D_property_sleeping:
  410. - :ref:`bool<class_bool>` **sleeping**
  411. +-----------+---------------------+
  412. | *Default* | ``false`` |
  413. +-----------+---------------------+
  414. | *Setter* | set_sleeping(value) |
  415. +-----------+---------------------+
  416. | *Getter* | is_sleeping() |
  417. +-----------+---------------------+
  418. 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_RigidDynamicBody3D_method_apply_impulse>` or :ref:`apply_force<class_RigidDynamicBody3D_method_apply_force>` methods.
  419. Method Descriptions
  420. -------------------
  421. .. _class_RigidDynamicBody3D_method__integrate_forces:
  422. - void **_integrate_forces** **(** :ref:`PhysicsDirectBodyState3D<class_PhysicsDirectBodyState3D>` state **)** |virtual|
  423. 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_RigidDynamicBody3D_property_custom_integrator>` property allows you to disable the default behavior and do fully custom force integration for a body.
  424. ----
  425. .. _class_RigidDynamicBody3D_method_add_constant_central_force:
  426. - void **add_constant_central_force** **(** :ref:`Vector3<class_Vector3>` force **)**
  427. Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with ``constant_force = Vector3(0, 0, 0)``.
  428. This is equivalent to using :ref:`add_constant_force<class_RigidDynamicBody3D_method_add_constant_force>` at the body's center of mass.
  429. ----
  430. .. _class_RigidDynamicBody3D_method_add_constant_force:
  431. - void **add_constant_force** **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position=Vector3(0, 0, 0) **)**
  432. Adds a constant positioned force to the body that keeps being applied over time until cleared with ``constant_force = Vector3(0, 0, 0)``.
  433. \ ``position`` is the offset from the body origin in global coordinates.
  434. ----
  435. .. _class_RigidDynamicBody3D_method_add_constant_torque:
  436. - void **add_constant_torque** **(** :ref:`Vector3<class_Vector3>` torque **)**
  437. Adds a constant rotational force without affecting position that keeps being applied over time until cleared with ``constant_torque = Vector3(0, 0, 0)``.
  438. ----
  439. .. _class_RigidDynamicBody3D_method_apply_central_force:
  440. - void **apply_central_force** **(** :ref:`Vector3<class_Vector3>` force **)**
  441. Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
  442. This is equivalent to using :ref:`apply_force<class_RigidDynamicBody3D_method_apply_force>` at the body's center of mass.
  443. ----
  444. .. _class_RigidDynamicBody3D_method_apply_central_impulse:
  445. - void **apply_central_impulse** **(** :ref:`Vector3<class_Vector3>` impulse **)**
  446. Applies a directional impulse without affecting rotation.
  447. 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 (use the "_force" functions otherwise).
  448. This is equivalent to using :ref:`apply_impulse<class_RigidDynamicBody3D_method_apply_impulse>` at the body's center of mass.
  449. ----
  450. .. _class_RigidDynamicBody3D_method_apply_force:
  451. - void **apply_force** **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position=Vector3(0, 0, 0) **)**
  452. Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
  453. \ ``position`` is the offset from the body origin in global coordinates.
  454. ----
  455. .. _class_RigidDynamicBody3D_method_apply_impulse:
  456. - void **apply_impulse** **(** :ref:`Vector3<class_Vector3>` impulse, :ref:`Vector3<class_Vector3>` position=Vector3(0, 0, 0) **)**
  457. Applies a positioned impulse to the body.
  458. 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 (use the "_force" functions otherwise).
  459. \ ``position`` is the offset from the body origin in global coordinates.
  460. ----
  461. .. _class_RigidDynamicBody3D_method_apply_torque:
  462. - void **apply_torque** **(** :ref:`Vector3<class_Vector3>` torque **)**
  463. Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
  464. ----
  465. .. _class_RigidDynamicBody3D_method_apply_torque_impulse:
  466. - void **apply_torque_impulse** **(** :ref:`Vector3<class_Vector3>` impulse **)**
  467. Applies a rotational impulse to the body without affecting the position.
  468. 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 (use the "_force" functions otherwise).
  469. ----
  470. .. _class_RigidDynamicBody3D_method_get_colliding_bodies:
  471. - :ref:`Array<class_Array>` **get_colliding_bodies** **(** **)** |const|
  472. Returns a list of the bodies colliding with this one. Requires :ref:`contact_monitor<class_RigidDynamicBody3D_property_contact_monitor>` to be set to ``true`` and :ref:`contacts_reported<class_RigidDynamicBody3D_property_contacts_reported>` to be set high enough to detect all the collisions.
  473. \ **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.
  474. ----
  475. .. _class_RigidDynamicBody3D_method_get_inverse_inertia_tensor:
  476. - :ref:`Basis<class_Basis>` **get_inverse_inertia_tensor** **(** **)** |const|
  477. Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the ``RigidDynamicBody3D``.
  478. ----
  479. .. _class_RigidDynamicBody3D_method_set_axis_velocity:
  480. - void **set_axis_velocity** **(** :ref:`Vector3<class_Vector3>` axis_velocity **)**
  481. 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.
  482. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  483. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  484. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  485. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  486. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  487. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`