Physics2DDirectBodyState.xml 7.7 KB

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