Physics2DDirectBodyState.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Physics2DDirectBodyState" inherits="Object" version="3.3">
  3. <brief_description>
  4. Direct access object to a physics body in the [Physics2DServer].
  5. </brief_description>
  6. <description>
  7. Provides direct access to a physics body in the [Physics2DServer], 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 [method RigidBody2D._integrate_forces].
  8. </description>
  9. <tutorials>
  10. <link>https://docs.godotengine.org/en/3.3/tutorials/physics/ray-casting.html</link>
  11. </tutorials>
  12. <methods>
  13. <method name="add_central_force">
  14. <return type="void" />
  15. <argument index="0" name="force" type="Vector2" />
  16. <description>
  17. Adds a constant directional force without affecting rotation.
  18. </description>
  19. </method>
  20. <method name="add_force">
  21. <return type="void" />
  22. <argument index="0" name="offset" type="Vector2" />
  23. <argument index="1" name="force" type="Vector2" />
  24. <description>
  25. Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
  26. </description>
  27. </method>
  28. <method name="add_torque">
  29. <return type="void" />
  30. <argument index="0" name="torque" type="float" />
  31. <description>
  32. Adds a constant rotational force.
  33. </description>
  34. </method>
  35. <method name="apply_central_impulse">
  36. <return type="void" />
  37. <argument index="0" name="impulse" type="Vector2" />
  38. <description>
  39. Applies a directional impulse without affecting rotation.
  40. </description>
  41. </method>
  42. <method name="apply_impulse">
  43. <return type="void" />
  44. <argument index="0" name="offset" type="Vector2" />
  45. <argument index="1" name="impulse" type="Vector2" />
  46. <description>
  47. 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 (use the "_force" functions otherwise). The offset uses the rotation of the global coordinate system, but is centered at the object's origin.
  48. </description>
  49. </method>
  50. <method name="apply_torque_impulse">
  51. <return type="void" />
  52. <argument index="0" name="impulse" type="float" />
  53. <description>
  54. Applies a rotational impulse to the body.
  55. </description>
  56. </method>
  57. <method name="get_contact_collider" qualifiers="const">
  58. <return type="RID" />
  59. <argument index="0" name="contact_idx" type="int" />
  60. <description>
  61. Returns the collider's [RID].
  62. </description>
  63. </method>
  64. <method name="get_contact_collider_id" qualifiers="const">
  65. <return type="int" />
  66. <argument index="0" name="contact_idx" type="int" />
  67. <description>
  68. Returns the collider's object id.
  69. </description>
  70. </method>
  71. <method name="get_contact_collider_object" qualifiers="const">
  72. <return type="Object" />
  73. <argument index="0" name="contact_idx" type="int" />
  74. <description>
  75. Returns the collider object. This depends on how it was created (will return a scene node if such was used to create it).
  76. </description>
  77. </method>
  78. <method name="get_contact_collider_position" qualifiers="const">
  79. <return type="Vector2" />
  80. <argument index="0" name="contact_idx" type="int" />
  81. <description>
  82. Returns the contact position in the collider.
  83. </description>
  84. </method>
  85. <method name="get_contact_collider_shape" qualifiers="const">
  86. <return type="int" />
  87. <argument index="0" name="contact_idx" type="int" />
  88. <description>
  89. Returns the collider's shape index.
  90. </description>
  91. </method>
  92. <method name="get_contact_collider_shape_metadata" qualifiers="const">
  93. <return type="Variant" />
  94. <argument index="0" name="contact_idx" type="int" />
  95. <description>
  96. Returns the collided shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data].
  97. </description>
  98. </method>
  99. <method name="get_contact_collider_velocity_at_position" qualifiers="const">
  100. <return type="Vector2" />
  101. <argument index="0" name="contact_idx" type="int" />
  102. <description>
  103. Returns the linear velocity vector at the collider's contact point.
  104. </description>
  105. </method>
  106. <method name="get_contact_count" qualifiers="const">
  107. <return type="int" />
  108. <description>
  109. Returns the number of contacts this body has with other bodies.
  110. [b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody2D.contact_monitor].
  111. </description>
  112. </method>
  113. <method name="get_contact_local_normal" qualifiers="const">
  114. <return type="Vector2" />
  115. <argument index="0" name="contact_idx" type="int" />
  116. <description>
  117. Returns the local normal at the contact point.
  118. </description>
  119. </method>
  120. <method name="get_contact_local_position" qualifiers="const">
  121. <return type="Vector2" />
  122. <argument index="0" name="contact_idx" type="int" />
  123. <description>
  124. Returns the local position of the contact point.
  125. </description>
  126. </method>
  127. <method name="get_contact_local_shape" qualifiers="const">
  128. <return type="int" />
  129. <argument index="0" name="contact_idx" type="int" />
  130. <description>
  131. Returns the local shape index of the collision.
  132. </description>
  133. </method>
  134. <method name="get_space_state">
  135. <return type="Physics2DDirectSpaceState" />
  136. <description>
  137. Returns the current state of the space, useful for queries.
  138. </description>
  139. </method>
  140. <method name="integrate_forces">
  141. <return type="void" />
  142. <description>
  143. Calls the built-in force integration code.
  144. </description>
  145. </method>
  146. </methods>
  147. <members>
  148. <member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity">
  149. The body's rotational velocity.
  150. </member>
  151. <member name="inverse_inertia" type="float" setter="" getter="get_inverse_inertia">
  152. The inverse of the inertia of the body.
  153. </member>
  154. <member name="inverse_mass" type="float" setter="" getter="get_inverse_mass">
  155. The inverse of the mass of the body.
  156. </member>
  157. <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity">
  158. The body's linear velocity.
  159. </member>
  160. <member name="sleeping" type="bool" setter="set_sleep_state" getter="is_sleeping">
  161. If [code]true[/code], this body is currently sleeping (not active).
  162. </member>
  163. <member name="step" type="float" setter="" getter="get_step">
  164. The timestep (delta) used for the simulation.
  165. </member>
  166. <member name="total_angular_damp" type="float" setter="" getter="get_total_angular_damp">
  167. The rate at which the body stops rotating, if there are not any other forces moving it.
  168. </member>
  169. <member name="total_gravity" type="Vector2" setter="" getter="get_total_gravity">
  170. The total gravity vector being currently applied to this body.
  171. </member>
  172. <member name="total_linear_damp" type="float" setter="" getter="get_total_linear_damp">
  173. The rate at which the body stops moving, if there are not any other forces moving it.
  174. </member>
  175. <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform">
  176. The body's transformation matrix.
  177. </member>
  178. </members>
  179. <constants>
  180. </constants>
  181. </class>