class_physicsdirectbodystate.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. **Category:** Core
  11. Brief Description
  12. -----------------
  13. Direct access object to a physics body in the :ref:`PhysicsServer<class_PhysicsServer>`.
  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. Description
  83. -----------
  84. 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>`.
  85. Property Descriptions
  86. ---------------------
  87. .. _class_PhysicsDirectBodyState_property_angular_velocity:
  88. - :ref:`Vector3<class_Vector3>` **angular_velocity**
  89. +----------+-----------------------------+
  90. | *Setter* | set_angular_velocity(value) |
  91. +----------+-----------------------------+
  92. | *Getter* | get_angular_velocity() |
  93. +----------+-----------------------------+
  94. The body's rotational velocity.
  95. ----
  96. .. _class_PhysicsDirectBodyState_property_center_of_mass:
  97. - :ref:`Vector3<class_Vector3>` **center_of_mass**
  98. +----------+----------------------+
  99. | *Getter* | get_center_of_mass() |
  100. +----------+----------------------+
  101. ----
  102. .. _class_PhysicsDirectBodyState_property_inverse_inertia:
  103. - :ref:`Vector3<class_Vector3>` **inverse_inertia**
  104. +----------+-----------------------+
  105. | *Getter* | get_inverse_inertia() |
  106. +----------+-----------------------+
  107. The inverse of the inertia of the body.
  108. ----
  109. .. _class_PhysicsDirectBodyState_property_inverse_mass:
  110. - :ref:`float<class_float>` **inverse_mass**
  111. +----------+--------------------+
  112. | *Getter* | get_inverse_mass() |
  113. +----------+--------------------+
  114. The inverse of the mass of the body.
  115. ----
  116. .. _class_PhysicsDirectBodyState_property_linear_velocity:
  117. - :ref:`Vector3<class_Vector3>` **linear_velocity**
  118. +----------+----------------------------+
  119. | *Setter* | set_linear_velocity(value) |
  120. +----------+----------------------------+
  121. | *Getter* | get_linear_velocity() |
  122. +----------+----------------------------+
  123. The body's linear velocity.
  124. ----
  125. .. _class_PhysicsDirectBodyState_property_principal_inertia_axes:
  126. - :ref:`Basis<class_Basis>` **principal_inertia_axes**
  127. +----------+------------------------------+
  128. | *Getter* | get_principal_inertia_axes() |
  129. +----------+------------------------------+
  130. ----
  131. .. _class_PhysicsDirectBodyState_property_sleeping:
  132. - :ref:`bool<class_bool>` **sleeping**
  133. +----------+------------------------+
  134. | *Setter* | set_sleep_state(value) |
  135. +----------+------------------------+
  136. | *Getter* | is_sleeping() |
  137. +----------+------------------------+
  138. If ``true``, this body is currently sleeping (not active).
  139. ----
  140. .. _class_PhysicsDirectBodyState_property_step:
  141. - :ref:`float<class_float>` **step**
  142. +----------+------------+
  143. | *Getter* | get_step() |
  144. +----------+------------+
  145. The timestep (delta) used for the simulation.
  146. ----
  147. .. _class_PhysicsDirectBodyState_property_total_angular_damp:
  148. - :ref:`float<class_float>` **total_angular_damp**
  149. +----------+--------------------------+
  150. | *Getter* | get_total_angular_damp() |
  151. +----------+--------------------------+
  152. The rate at which the body stops rotating, if there are not any other forces moving it.
  153. ----
  154. .. _class_PhysicsDirectBodyState_property_total_gravity:
  155. - :ref:`Vector3<class_Vector3>` **total_gravity**
  156. +----------+---------------------+
  157. | *Getter* | get_total_gravity() |
  158. +----------+---------------------+
  159. The total gravity vector being currently applied to this body.
  160. ----
  161. .. _class_PhysicsDirectBodyState_property_total_linear_damp:
  162. - :ref:`float<class_float>` **total_linear_damp**
  163. +----------+-------------------------+
  164. | *Getter* | get_total_linear_damp() |
  165. +----------+-------------------------+
  166. The rate at which the body stops moving, if there are not any other forces moving it.
  167. ----
  168. .. _class_PhysicsDirectBodyState_property_transform:
  169. - :ref:`Transform<class_Transform>` **transform**
  170. +----------+----------------------+
  171. | *Setter* | set_transform(value) |
  172. +----------+----------------------+
  173. | *Getter* | get_transform() |
  174. +----------+----------------------+
  175. The body's transformation matrix.
  176. Method Descriptions
  177. -------------------
  178. .. _class_PhysicsDirectBodyState_method_add_central_force:
  179. - void **add_central_force** **(** :ref:`Vector3<class_Vector3>` force **)**
  180. Adds a constant directional force without affecting rotation.
  181. This is equivalent to ``add_force(force, Vector3(0,0,0))``.
  182. ----
  183. .. _class_PhysicsDirectBodyState_method_add_force:
  184. - void **add_force** **(** :ref:`Vector3<class_Vector3>` force, :ref:`Vector3<class_Vector3>` position **)**
  185. Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
  186. ----
  187. .. _class_PhysicsDirectBodyState_method_add_torque:
  188. - void **add_torque** **(** :ref:`Vector3<class_Vector3>` torque **)**
  189. Adds a constant rotational force without affecting position.
  190. ----
  191. .. _class_PhysicsDirectBodyState_method_apply_central_impulse:
  192. - void **apply_central_impulse** **(** :ref:`Vector3<class_Vector3>` j **)**
  193. Applies a single directional impulse without affecting rotation.
  194. This is equivalent to ``apply_impulse(Vector3(0, 0, 0), impulse)``.
  195. ----
  196. .. _class_PhysicsDirectBodyState_method_apply_impulse:
  197. - void **apply_impulse** **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` j **)**
  198. 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.
  199. ----
  200. .. _class_PhysicsDirectBodyState_method_apply_torque_impulse:
  201. - void **apply_torque_impulse** **(** :ref:`Vector3<class_Vector3>` j **)**
  202. Apply a torque impulse (which will be affected by the body mass and shape). This will rotate the body around the passed in vector.
  203. ----
  204. .. _class_PhysicsDirectBodyState_method_get_contact_collider:
  205. - :ref:`RID<class_RID>` **get_contact_collider** **(** :ref:`int<class_int>` contact_idx **)** const
  206. Returns the collider's :ref:`RID<class_RID>`.
  207. ----
  208. .. _class_PhysicsDirectBodyState_method_get_contact_collider_id:
  209. - :ref:`int<class_int>` **get_contact_collider_id** **(** :ref:`int<class_int>` contact_idx **)** const
  210. Returns the collider's object id.
  211. ----
  212. .. _class_PhysicsDirectBodyState_method_get_contact_collider_object:
  213. - :ref:`Object<class_Object>` **get_contact_collider_object** **(** :ref:`int<class_int>` contact_idx **)** const
  214. Returns the collider object.
  215. ----
  216. .. _class_PhysicsDirectBodyState_method_get_contact_collider_position:
  217. - :ref:`Vector3<class_Vector3>` **get_contact_collider_position** **(** :ref:`int<class_int>` contact_idx **)** const
  218. Returns the contact position in the collider.
  219. ----
  220. .. _class_PhysicsDirectBodyState_method_get_contact_collider_shape:
  221. - :ref:`int<class_int>` **get_contact_collider_shape** **(** :ref:`int<class_int>` contact_idx **)** const
  222. Returns the collider's shape index.
  223. ----
  224. .. _class_PhysicsDirectBodyState_method_get_contact_collider_velocity_at_position:
  225. - :ref:`Vector3<class_Vector3>` **get_contact_collider_velocity_at_position** **(** :ref:`int<class_int>` contact_idx **)** const
  226. Returns the linear velocity vector at the collider's contact point.
  227. ----
  228. .. _class_PhysicsDirectBodyState_method_get_contact_count:
  229. - :ref:`int<class_int>` **get_contact_count** **(** **)** const
  230. Returns the number of contacts this body has with other bodies. Note that by default this returns 0 unless bodies are configured to log contacts. See :ref:`RigidBody.contact_monitor<class_RigidBody_property_contact_monitor>`.
  231. ----
  232. .. _class_PhysicsDirectBodyState_method_get_contact_impulse:
  233. - :ref:`float<class_float>` **get_contact_impulse** **(** :ref:`int<class_int>` contact_idx **)** const
  234. Impulse created by the contact. Only implemented for Bullet physics.
  235. ----
  236. .. _class_PhysicsDirectBodyState_method_get_contact_local_normal:
  237. - :ref:`Vector3<class_Vector3>` **get_contact_local_normal** **(** :ref:`int<class_int>` contact_idx **)** const
  238. Returns the local normal at the contact point.
  239. ----
  240. .. _class_PhysicsDirectBodyState_method_get_contact_local_position:
  241. - :ref:`Vector3<class_Vector3>` **get_contact_local_position** **(** :ref:`int<class_int>` contact_idx **)** const
  242. Returns the local position of the contact point.
  243. ----
  244. .. _class_PhysicsDirectBodyState_method_get_contact_local_shape:
  245. - :ref:`int<class_int>` **get_contact_local_shape** **(** :ref:`int<class_int>` contact_idx **)** const
  246. Returns the local shape index of the collision.
  247. ----
  248. .. _class_PhysicsDirectBodyState_method_get_space_state:
  249. - :ref:`PhysicsDirectSpaceState<class_PhysicsDirectSpaceState>` **get_space_state** **(** **)**
  250. Returns the current state of the space, useful for queries.
  251. ----
  252. .. _class_PhysicsDirectBodyState_method_integrate_forces:
  253. - void **integrate_forces** **(** **)**
  254. Calls the built-in force integration code.