Physics2DDirectBodyState.xml 7.7 KB

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