class_physicsdirectbodystate.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the PhysicsDirectBodyState.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_PhysicsDirectBodyState:
  6. PhysicsDirectBodyState
  7. ======================
  8. **Inherits:** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`BulletPhysicsDirectBodyState<class_BulletPhysicsDirectBodyState>`
  10. Direct access object to a physics body in the :ref:`PhysicsServer<class_PhysicsServer>`.
  11. Description
  12. -----------
  13. Provides direct access to a physics body in the :ref:`PhysicsServer<class_PhysicsServer>`, allowing safe changes to physics properties. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body. See :ref:`RigidBody._integrate_forces<class_RigidBody_method__integrate_forces>`.
  14. Properties
  15. ----------
  16. +-----------------------------------+---------------------------------------------------------------------------------------------+
  17. | :ref:`Vector3<class_Vector3>` | :ref:`angular_velocity<class_PhysicsDirectBodyState_property_angular_velocity>` |
  18. +-----------------------------------+---------------------------------------------------------------------------------------------+
  19. | :ref:`Vector3<class_Vector3>` | :ref:`center_of_mass<class_PhysicsDirectBodyState_property_center_of_mass>` |
  20. +-----------------------------------+---------------------------------------------------------------------------------------------+
  21. | :ref:`Vector3<class_Vector3>` | :ref:`inverse_inertia<class_PhysicsDirectBodyState_property_inverse_inertia>` |
  22. +-----------------------------------+---------------------------------------------------------------------------------------------+
  23. | :ref:`float<class_float>` | :ref:`inverse_mass<class_PhysicsDirectBodyState_property_inverse_mass>` |
  24. +-----------------------------------+---------------------------------------------------------------------------------------------+
  25. | :ref:`Vector3<class_Vector3>` | :ref:`linear_velocity<class_PhysicsDirectBodyState_property_linear_velocity>` |
  26. +-----------------------------------+---------------------------------------------------------------------------------------------+
  27. | :ref:`Basis<class_Basis>` | :ref:`principal_inertia_axes<class_PhysicsDirectBodyState_property_principal_inertia_axes>` |
  28. +-----------------------------------+---------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`sleeping<class_PhysicsDirectBodyState_property_sleeping>` |
  30. +-----------------------------------+---------------------------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`step<class_PhysicsDirectBodyState_property_step>` |
  32. +-----------------------------------+---------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`total_angular_damp<class_PhysicsDirectBodyState_property_total_angular_damp>` |
  34. +-----------------------------------+---------------------------------------------------------------------------------------------+
  35. | :ref:`Vector3<class_Vector3>` | :ref:`total_gravity<class_PhysicsDirectBodyState_property_total_gravity>` |
  36. +-----------------------------------+---------------------------------------------------------------------------------------------+
  37. | :ref:`float<class_float>` | :ref:`total_linear_damp<class_PhysicsDirectBodyState_property_total_linear_damp>` |
  38. +-----------------------------------+---------------------------------------------------------------------------------------------+
  39. | :ref:`Transform<class_Transform>` | :ref:`transform<class_PhysicsDirectBodyState_property_transform>` |
  40. +-----------------------------------+---------------------------------------------------------------------------------------------+
  41. Methods
  42. -------
  43. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`add_central_force<class_PhysicsDirectBodyState_method_add_central_force>` **(** :ref:`Vector3<class_Vector3>` force **)** |
  45. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`add_force<class_PhysicsDirectBodyState_method_add_force>` **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position **)** |
  47. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`add_torque<class_PhysicsDirectBodyState_method_add_torque>` **(** :ref:`Vector3<class_Vector3>` torque **)** |
  49. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`apply_central_impulse<class_PhysicsDirectBodyState_method_apply_central_impulse>` **(** :ref:`Vector3<class_Vector3>` j **)** |
  51. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`apply_impulse<class_PhysicsDirectBodyState_method_apply_impulse>` **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` j **)** |
  53. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`apply_torque_impulse<class_PhysicsDirectBodyState_method_apply_torque_impulse>` **(** :ref:`Vector3<class_Vector3>` j **)** |
  55. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`RID<class_RID>` | :ref:`get_contact_collider<class_PhysicsDirectBodyState_method_get_contact_collider>` **(** :ref:`int<class_int>` contact_idx **)** const |
  57. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`int<class_int>` | :ref:`get_contact_collider_id<class_PhysicsDirectBodyState_method_get_contact_collider_id>` **(** :ref:`int<class_int>` contact_idx **)** const |
  59. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Object<class_Object>` | :ref:`get_contact_collider_object<class_PhysicsDirectBodyState_method_get_contact_collider_object>` **(** :ref:`int<class_int>` contact_idx **)** const |
  61. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Vector3<class_Vector3>` | :ref:`get_contact_collider_position<class_PhysicsDirectBodyState_method_get_contact_collider_position>` **(** :ref:`int<class_int>` contact_idx **)** const |
  63. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`int<class_int>` | :ref:`get_contact_collider_shape<class_PhysicsDirectBodyState_method_get_contact_collider_shape>` **(** :ref:`int<class_int>` contact_idx **)** const |
  65. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Vector3<class_Vector3>` | :ref:`get_contact_collider_velocity_at_position<class_PhysicsDirectBodyState_method_get_contact_collider_velocity_at_position>` **(** :ref:`int<class_int>` contact_idx **)** const |
  67. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`int<class_int>` | :ref:`get_contact_count<class_PhysicsDirectBodyState_method_get_contact_count>` **(** **)** const |
  69. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`float<class_float>` | :ref:`get_contact_impulse<class_PhysicsDirectBodyState_method_get_contact_impulse>` **(** :ref:`int<class_int>` contact_idx **)** const |
  71. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Vector3<class_Vector3>` | :ref:`get_contact_local_normal<class_PhysicsDirectBodyState_method_get_contact_local_normal>` **(** :ref:`int<class_int>` contact_idx **)** const |
  73. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`Vector3<class_Vector3>` | :ref:`get_contact_local_position<class_PhysicsDirectBodyState_method_get_contact_local_position>` **(** :ref:`int<class_int>` contact_idx **)** const |
  75. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`int<class_int>` | :ref:`get_contact_local_shape<class_PhysicsDirectBodyState_method_get_contact_local_shape>` **(** :ref:`int<class_int>` contact_idx **)** const |
  77. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`PhysicsDirectSpaceState<class_PhysicsDirectSpaceState>` | :ref:`get_space_state<class_PhysicsDirectBodyState_method_get_space_state>` **(** **)** |
  79. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`integrate_forces<class_PhysicsDirectBodyState_method_integrate_forces>` **(** **)** |
  81. +---------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. Property Descriptions
  83. ---------------------
  84. .. _class_PhysicsDirectBodyState_property_angular_velocity:
  85. - :ref:`Vector3<class_Vector3>` **angular_velocity**
  86. +----------+-----------------------------+
  87. | *Setter* | set_angular_velocity(value) |
  88. +----------+-----------------------------+
  89. | *Getter* | get_angular_velocity() |
  90. +----------+-----------------------------+
  91. The body's rotational velocity.
  92. ----
  93. .. _class_PhysicsDirectBodyState_property_center_of_mass:
  94. - :ref:`Vector3<class_Vector3>` **center_of_mass**
  95. +----------+----------------------+
  96. | *Getter* | get_center_of_mass() |
  97. +----------+----------------------+
  98. ----
  99. .. _class_PhysicsDirectBodyState_property_inverse_inertia:
  100. - :ref:`Vector3<class_Vector3>` **inverse_inertia**
  101. +----------+-----------------------+
  102. | *Getter* | get_inverse_inertia() |
  103. +----------+-----------------------+
  104. The inverse of the inertia of the body.
  105. ----
  106. .. _class_PhysicsDirectBodyState_property_inverse_mass:
  107. - :ref:`float<class_float>` **inverse_mass**
  108. +----------+--------------------+
  109. | *Getter* | get_inverse_mass() |
  110. +----------+--------------------+
  111. The inverse of the mass of the body.
  112. ----
  113. .. _class_PhysicsDirectBodyState_property_linear_velocity:
  114. - :ref:`Vector3<class_Vector3>` **linear_velocity**
  115. +----------+----------------------------+
  116. | *Setter* | set_linear_velocity(value) |
  117. +----------+----------------------------+
  118. | *Getter* | get_linear_velocity() |
  119. +----------+----------------------------+
  120. The body's linear velocity.
  121. ----
  122. .. _class_PhysicsDirectBodyState_property_principal_inertia_axes:
  123. - :ref:`Basis<class_Basis>` **principal_inertia_axes**
  124. +----------+------------------------------+
  125. | *Getter* | get_principal_inertia_axes() |
  126. +----------+------------------------------+
  127. ----
  128. .. _class_PhysicsDirectBodyState_property_sleeping:
  129. - :ref:`bool<class_bool>` **sleeping**
  130. +----------+------------------------+
  131. | *Setter* | set_sleep_state(value) |
  132. +----------+------------------------+
  133. | *Getter* | is_sleeping() |
  134. +----------+------------------------+
  135. If ``true``, this body is currently sleeping (not active).
  136. ----
  137. .. _class_PhysicsDirectBodyState_property_step:
  138. - :ref:`float<class_float>` **step**
  139. +----------+------------+
  140. | *Getter* | get_step() |
  141. +----------+------------+
  142. The timestep (delta) used for the simulation.
  143. ----
  144. .. _class_PhysicsDirectBodyState_property_total_angular_damp:
  145. - :ref:`float<class_float>` **total_angular_damp**
  146. +----------+--------------------------+
  147. | *Getter* | get_total_angular_damp() |
  148. +----------+--------------------------+
  149. The rate at which the body stops rotating, if there are not any other forces moving it.
  150. ----
  151. .. _class_PhysicsDirectBodyState_property_total_gravity:
  152. - :ref:`Vector3<class_Vector3>` **total_gravity**
  153. +----------+---------------------+
  154. | *Getter* | get_total_gravity() |
  155. +----------+---------------------+
  156. The total gravity vector being currently applied to this body.
  157. ----
  158. .. _class_PhysicsDirectBodyState_property_total_linear_damp:
  159. - :ref:`float<class_float>` **total_linear_damp**
  160. +----------+-------------------------+
  161. | *Getter* | get_total_linear_damp() |
  162. +----------+-------------------------+
  163. The rate at which the body stops moving, if there are not any other forces moving it.
  164. ----
  165. .. _class_PhysicsDirectBodyState_property_transform:
  166. - :ref:`Transform<class_Transform>` **transform**
  167. +----------+----------------------+
  168. | *Setter* | set_transform(value) |
  169. +----------+----------------------+
  170. | *Getter* | get_transform() |
  171. +----------+----------------------+
  172. The body's transformation matrix.
  173. Method Descriptions
  174. -------------------
  175. .. _class_PhysicsDirectBodyState_method_add_central_force:
  176. - void **add_central_force** **(** :ref:`Vector3<class_Vector3>` force **)**
  177. Adds a constant directional force without affecting rotation.
  178. This is equivalent to ``add_force(force, Vector3(0,0,0))``.
  179. ----
  180. .. _class_PhysicsDirectBodyState_method_add_force:
  181. - void **add_force** **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position **)**
  182. Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
  183. ----
  184. .. _class_PhysicsDirectBodyState_method_add_torque:
  185. - void **add_torque** **(** :ref:`Vector3<class_Vector3>` torque **)**
  186. Adds a constant rotational force without affecting position.
  187. ----
  188. .. _class_PhysicsDirectBodyState_method_apply_central_impulse:
  189. - void **apply_central_impulse** **(** :ref:`Vector3<class_Vector3>` j **)**
  190. Applies a single directional impulse without affecting rotation.
  191. This is equivalent to ``apply_impulse(Vector3(0, 0, 0), impulse)``.
  192. ----
  193. .. _class_PhysicsDirectBodyState_method_apply_impulse:
  194. - void **apply_impulse** **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` j **)**
  195. 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.
  196. ----
  197. .. _class_PhysicsDirectBodyState_method_apply_torque_impulse:
  198. - void **apply_torque_impulse** **(** :ref:`Vector3<class_Vector3>` j **)**
  199. Apply a torque impulse (which will be affected by the body mass and shape). This will rotate the body around the vector ``j`` passed as parameter.
  200. ----
  201. .. _class_PhysicsDirectBodyState_method_get_contact_collider:
  202. - :ref:`RID<class_RID>` **get_contact_collider** **(** :ref:`int<class_int>` contact_idx **)** const
  203. Returns the collider's :ref:`RID<class_RID>`.
  204. ----
  205. .. _class_PhysicsDirectBodyState_method_get_contact_collider_id:
  206. - :ref:`int<class_int>` **get_contact_collider_id** **(** :ref:`int<class_int>` contact_idx **)** const
  207. Returns the collider's object id.
  208. ----
  209. .. _class_PhysicsDirectBodyState_method_get_contact_collider_object:
  210. - :ref:`Object<class_Object>` **get_contact_collider_object** **(** :ref:`int<class_int>` contact_idx **)** const
  211. Returns the collider object.
  212. ----
  213. .. _class_PhysicsDirectBodyState_method_get_contact_collider_position:
  214. - :ref:`Vector3<class_Vector3>` **get_contact_collider_position** **(** :ref:`int<class_int>` contact_idx **)** const
  215. Returns the contact position in the collider.
  216. ----
  217. .. _class_PhysicsDirectBodyState_method_get_contact_collider_shape:
  218. - :ref:`int<class_int>` **get_contact_collider_shape** **(** :ref:`int<class_int>` contact_idx **)** const
  219. Returns the collider's shape index.
  220. ----
  221. .. _class_PhysicsDirectBodyState_method_get_contact_collider_velocity_at_position:
  222. - :ref:`Vector3<class_Vector3>` **get_contact_collider_velocity_at_position** **(** :ref:`int<class_int>` contact_idx **)** const
  223. Returns the linear velocity vector at the collider's contact point.
  224. ----
  225. .. _class_PhysicsDirectBodyState_method_get_contact_count:
  226. - :ref:`int<class_int>` **get_contact_count** **(** **)** const
  227. Returns the number of contacts this body has with other bodies.
  228. **Note:** By default, this returns 0 unless bodies are configured to monitor contacts. See :ref:`RigidBody.contact_monitor<class_RigidBody_property_contact_monitor>`.
  229. ----
  230. .. _class_PhysicsDirectBodyState_method_get_contact_impulse:
  231. - :ref:`float<class_float>` **get_contact_impulse** **(** :ref:`int<class_int>` contact_idx **)** const
  232. Impulse created by the contact. Only implemented for Bullet physics.
  233. ----
  234. .. _class_PhysicsDirectBodyState_method_get_contact_local_normal:
  235. - :ref:`Vector3<class_Vector3>` **get_contact_local_normal** **(** :ref:`int<class_int>` contact_idx **)** const
  236. Returns the local normal at the contact point.
  237. ----
  238. .. _class_PhysicsDirectBodyState_method_get_contact_local_position:
  239. - :ref:`Vector3<class_Vector3>` **get_contact_local_position** **(** :ref:`int<class_int>` contact_idx **)** const
  240. Returns the local position of the contact point.
  241. ----
  242. .. _class_PhysicsDirectBodyState_method_get_contact_local_shape:
  243. - :ref:`int<class_int>` **get_contact_local_shape** **(** :ref:`int<class_int>` contact_idx **)** const
  244. Returns the local shape index of the collision.
  245. ----
  246. .. _class_PhysicsDirectBodyState_method_get_space_state:
  247. - :ref:`PhysicsDirectSpaceState<class_PhysicsDirectSpaceState>` **get_space_state** **(** **)**
  248. Returns the current state of the space, useful for queries.
  249. ----
  250. .. _class_PhysicsDirectBodyState_method_integrate_forces:
  251. - void **integrate_forces** **(** **)**
  252. Calls the built-in force integration code.