class_physicsdirectbodystate.rst 22 KB

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