class_physics2ddirectbodystate.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Physics2DDirectBodyState:
  4. Physics2DDirectBodyState
  5. ========================
  6. **Inherits:** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`Physics2DDirectBodyStateSW<class_physics2ddirectbodystatesw>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Direct access object to a physics body in the :ref:`Physics2DServer<class_physics2dserver>`.
  12. Member Functions
  13. ----------------
  14. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`float<class_float>` | :ref:`get_angular_velocity<class_Physics2DDirectBodyState_get_angular_velocity>` **(** **)** const |
  16. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`RID<class_rid>` | :ref:`get_contact_collider<class_Physics2DDirectBodyState_get_contact_collider>` **(** :ref:`int<class_int>` contact_idx **)** const |
  18. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`int<class_int>` | :ref:`get_contact_collider_id<class_Physics2DDirectBodyState_get_contact_collider_id>` **(** :ref:`int<class_int>` contact_idx **)** const |
  20. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Object<class_object>` | :ref:`get_contact_collider_object<class_Physics2DDirectBodyState_get_contact_collider_object>` **(** :ref:`int<class_int>` contact_idx **)** const |
  22. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Vector2<class_vector2>` | :ref:`get_contact_collider_pos<class_Physics2DDirectBodyState_get_contact_collider_pos>` **(** :ref:`int<class_int>` contact_idx **)** const |
  24. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`get_contact_collider_shape<class_Physics2DDirectBodyState_get_contact_collider_shape>` **(** :ref:`int<class_int>` contact_idx **)** const |
  26. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Variant<class_variant>` | :ref:`get_contact_collider_shape_metadata<class_Physics2DDirectBodyState_get_contact_collider_shape_metadata>` **(** :ref:`int<class_int>` contact_idx **)** const |
  28. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Vector2<class_vector2>` | :ref:`get_contact_collider_velocity_at_pos<class_Physics2DDirectBodyState_get_contact_collider_velocity_at_pos>` **(** :ref:`int<class_int>` contact_idx **)** const |
  30. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_contact_count<class_Physics2DDirectBodyState_get_contact_count>` **(** **)** const |
  32. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Vector2<class_vector2>` | :ref:`get_contact_local_normal<class_Physics2DDirectBodyState_get_contact_local_normal>` **(** :ref:`int<class_int>` contact_idx **)** const |
  34. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Vector2<class_vector2>` | :ref:`get_contact_local_pos<class_Physics2DDirectBodyState_get_contact_local_pos>` **(** :ref:`int<class_int>` contact_idx **)** const |
  36. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`get_contact_local_shape<class_Physics2DDirectBodyState_get_contact_local_shape>` **(** :ref:`int<class_int>` contact_idx **)** const |
  38. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`float<class_float>` | :ref:`get_inverse_inertia<class_Physics2DDirectBodyState_get_inverse_inertia>` **(** **)** const |
  40. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`float<class_float>` | :ref:`get_inverse_mass<class_Physics2DDirectBodyState_get_inverse_mass>` **(** **)** const |
  42. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Vector2<class_vector2>` | :ref:`get_linear_velocity<class_Physics2DDirectBodyState_get_linear_velocity>` **(** **)** const |
  44. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Physics2DDirectSpaceState<class_physics2ddirectspacestate>` | :ref:`get_space_state<class_Physics2DDirectBodyState_get_space_state>` **(** **)** |
  46. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`float<class_float>` | :ref:`get_step<class_Physics2DDirectBodyState_get_step>` **(** **)** const |
  48. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`get_total_angular_damp<class_Physics2DDirectBodyState_get_total_angular_damp>` **(** **)** const |
  50. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector2<class_vector2>` | :ref:`get_total_gravity<class_Physics2DDirectBodyState_get_total_gravity>` **(** **)** const |
  52. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`float<class_float>` | :ref:`get_total_linear_damp<class_Physics2DDirectBodyState_get_total_linear_damp>` **(** **)** const |
  54. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Matrix32<class_matrix32>` | :ref:`get_transform<class_Physics2DDirectBodyState_get_transform>` **(** **)** const |
  56. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`integrate_forces<class_Physics2DDirectBodyState_integrate_forces>` **(** **)** |
  58. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`is_sleeping<class_Physics2DDirectBodyState_is_sleeping>` **(** **)** const |
  60. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_angular_velocity<class_Physics2DDirectBodyState_set_angular_velocity>` **(** :ref:`float<class_float>` velocity **)** |
  62. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_linear_velocity<class_Physics2DDirectBodyState_set_linear_velocity>` **(** :ref:`Vector2<class_vector2>` velocity **)** |
  64. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`set_sleep_state<class_Physics2DDirectBodyState_set_sleep_state>` **(** :ref:`bool<class_bool>` enabled **)** |
  66. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_transform<class_Physics2DDirectBodyState_set_transform>` **(** :ref:`Matrix32<class_matrix32>` transform **)** |
  68. +--------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. Description
  70. -----------
  71. Direct access object to a physics body in the :ref:`Physics2DServer<class_physics2dserver>`. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body.
  72. Member Function Description
  73. ---------------------------
  74. .. _class_Physics2DDirectBodyState_get_angular_velocity:
  75. - :ref:`float<class_float>` **get_angular_velocity** **(** **)** const
  76. Return the angular velocity of the body.
  77. .. _class_Physics2DDirectBodyState_get_contact_collider:
  78. - :ref:`RID<class_rid>` **get_contact_collider** **(** :ref:`int<class_int>` contact_idx **)** const
  79. Return the :ref:`RID<class_rid>` of the collider.
  80. .. _class_Physics2DDirectBodyState_get_contact_collider_id:
  81. - :ref:`int<class_int>` **get_contact_collider_id** **(** :ref:`int<class_int>` contact_idx **)** const
  82. Return the object id of the collider.
  83. .. _class_Physics2DDirectBodyState_get_contact_collider_object:
  84. - :ref:`Object<class_object>` **get_contact_collider_object** **(** :ref:`int<class_int>` contact_idx **)** const
  85. Return the collider object, this depends on how it was created (will return a scene node if such was used to create it).
  86. .. _class_Physics2DDirectBodyState_get_contact_collider_pos:
  87. - :ref:`Vector2<class_vector2>` **get_contact_collider_pos** **(** :ref:`int<class_int>` contact_idx **)** const
  88. Return the contact position in the collider.
  89. .. _class_Physics2DDirectBodyState_get_contact_collider_shape:
  90. - :ref:`int<class_int>` **get_contact_collider_shape** **(** :ref:`int<class_int>` contact_idx **)** const
  91. Return the collider shape index.
  92. .. _class_Physics2DDirectBodyState_get_contact_collider_shape_metadata:
  93. - :ref:`Variant<class_variant>` **get_contact_collider_shape_metadata** **(** :ref:`int<class_int>` contact_idx **)** const
  94. Return the metadata of the collided shape. This metadata is different from :ref:`Object.get_meta<class_Object_get_meta>`, and is set with :ref:`Physics2DServer.shape_set_data<class_Physics2DServer_shape_set_data>`.
  95. .. _class_Physics2DDirectBodyState_get_contact_collider_velocity_at_pos:
  96. - :ref:`Vector2<class_vector2>` **get_contact_collider_velocity_at_pos** **(** :ref:`int<class_int>` contact_idx **)** const
  97. Return the linear velocity vector at contact point of the collider.
  98. .. _class_Physics2DDirectBodyState_get_contact_count:
  99. - :ref:`int<class_int>` **get_contact_count** **(** **)** const
  100. Return the amount of contacts this body has with other bodies. Note that by default this returns 0 unless bodies are configured to log contacts.
  101. .. _class_Physics2DDirectBodyState_get_contact_local_normal:
  102. - :ref:`Vector2<class_vector2>` **get_contact_local_normal** **(** :ref:`int<class_int>` contact_idx **)** const
  103. Return the local normal (of this body) of the contact point.
  104. .. _class_Physics2DDirectBodyState_get_contact_local_pos:
  105. - :ref:`Vector2<class_vector2>` **get_contact_local_pos** **(** :ref:`int<class_int>` contact_idx **)** const
  106. Return the local position (of this body) of the contact point.
  107. .. _class_Physics2DDirectBodyState_get_contact_local_shape:
  108. - :ref:`int<class_int>` **get_contact_local_shape** **(** :ref:`int<class_int>` contact_idx **)** const
  109. Return the local shape index of the collision.
  110. .. _class_Physics2DDirectBodyState_get_inverse_inertia:
  111. - :ref:`float<class_float>` **get_inverse_inertia** **(** **)** const
  112. Return the inverse of the inertia of the body.
  113. .. _class_Physics2DDirectBodyState_get_inverse_mass:
  114. - :ref:`float<class_float>` **get_inverse_mass** **(** **)** const
  115. Return the inverse of the mass of the body.
  116. .. _class_Physics2DDirectBodyState_get_linear_velocity:
  117. - :ref:`Vector2<class_vector2>` **get_linear_velocity** **(** **)** const
  118. Return the current linear velocity of the body.
  119. .. _class_Physics2DDirectBodyState_get_space_state:
  120. - :ref:`Physics2DDirectSpaceState<class_physics2ddirectspacestate>` **get_space_state** **(** **)**
  121. Return the current state of space, useful for queries.
  122. .. _class_Physics2DDirectBodyState_get_step:
  123. - :ref:`float<class_float>` **get_step** **(** **)** const
  124. Return the timestep (delta) used for the simulation.
  125. .. _class_Physics2DDirectBodyState_get_total_angular_damp:
  126. - :ref:`float<class_float>` **get_total_angular_damp** **(** **)** const
  127. Return the rate at which the body stops rotating, if there are not any other forces moving it.
  128. .. _class_Physics2DDirectBodyState_get_total_gravity:
  129. - :ref:`Vector2<class_vector2>` **get_total_gravity** **(** **)** const
  130. Return the total gravity vector being currently applied to this body.
  131. .. _class_Physics2DDirectBodyState_get_total_linear_damp:
  132. - :ref:`float<class_float>` **get_total_linear_damp** **(** **)** const
  133. Return the rate at which the body stops moving, if there are not any other forces moving it.
  134. .. _class_Physics2DDirectBodyState_get_transform:
  135. - :ref:`Matrix32<class_matrix32>` **get_transform** **(** **)** const
  136. Return the transform matrix of the body.
  137. .. _class_Physics2DDirectBodyState_integrate_forces:
  138. - void **integrate_forces** **(** **)**
  139. Call the built-in force integration code.
  140. .. _class_Physics2DDirectBodyState_is_sleeping:
  141. - :ref:`bool<class_bool>` **is_sleeping** **(** **)** const
  142. Return true if this body is currently sleeping (not active).
  143. .. _class_Physics2DDirectBodyState_set_angular_velocity:
  144. - void **set_angular_velocity** **(** :ref:`float<class_float>` velocity **)**
  145. Change the angular velocity of the body.
  146. .. _class_Physics2DDirectBodyState_set_linear_velocity:
  147. - void **set_linear_velocity** **(** :ref:`Vector2<class_vector2>` velocity **)**
  148. Change the linear velocity of the body.
  149. .. _class_Physics2DDirectBodyState_set_sleep_state:
  150. - void **set_sleep_state** **(** :ref:`bool<class_bool>` enabled **)**
  151. Set the sleeping state of the body, only affects character/rigid bodies.
  152. .. _class_Physics2DDirectBodyState_set_transform:
  153. - void **set_transform** **(** :ref:`Matrix32<class_matrix32>` transform **)**
  154. Change the transform matrix of the body.