class_physics2ddirectbodystate.rst 20 KB

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