Physics2DDirectBodyState.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Physics2DDirectBodyState" inherits="Object" category="Core" version="3.1.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/3.1/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. Note that by default this returns 0 unless bodies are configured to log contacts. See [member RigidBody2D.contact_monitor].
  139. </description>
  140. </method>
  141. <method name="get_contact_local_normal" qualifiers="const">
  142. <return type="Vector2">
  143. </return>
  144. <argument index="0" name="contact_idx" type="int">
  145. </argument>
  146. <description>
  147. Returns the local normal at the contact point.
  148. </description>
  149. </method>
  150. <method name="get_contact_local_position" qualifiers="const">
  151. <return type="Vector2">
  152. </return>
  153. <argument index="0" name="contact_idx" type="int">
  154. </argument>
  155. <description>
  156. Returns the local position of the contact point.
  157. </description>
  158. </method>
  159. <method name="get_contact_local_shape" qualifiers="const">
  160. <return type="int">
  161. </return>
  162. <argument index="0" name="contact_idx" type="int">
  163. </argument>
  164. <description>
  165. Returns the local shape index of the collision.
  166. </description>
  167. </method>
  168. <method name="get_space_state">
  169. <return type="Physics2DDirectSpaceState">
  170. </return>
  171. <description>
  172. Returns the current state of the space, useful for queries.
  173. </description>
  174. </method>
  175. <method name="integrate_forces">
  176. <return type="void">
  177. </return>
  178. <description>
  179. Calls the built-in force integration code.
  180. </description>
  181. </method>
  182. </methods>
  183. <members>
  184. <member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity">
  185. The body's rotational velocity.
  186. </member>
  187. <member name="inverse_inertia" type="float" setter="" getter="get_inverse_inertia">
  188. The inverse of the inertia of the body.
  189. </member>
  190. <member name="inverse_mass" type="float" setter="" getter="get_inverse_mass">
  191. The inverse of the mass of the body.
  192. </member>
  193. <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity">
  194. The body's linear velocity.
  195. </member>
  196. <member name="sleeping" type="bool" setter="set_sleep_state" getter="is_sleeping">
  197. If [code]true[/code], this body is currently sleeping (not active).
  198. </member>
  199. <member name="step" type="float" setter="" getter="get_step">
  200. The timestep (delta) used for the simulation.
  201. </member>
  202. <member name="total_angular_damp" type="float" setter="" getter="get_total_angular_damp">
  203. The rate at which the body stops rotating, if there are not any other forces moving it.
  204. </member>
  205. <member name="total_gravity" type="Vector2" setter="" getter="get_total_gravity">
  206. The total gravity vector being currently applied to this body.
  207. </member>
  208. <member name="total_linear_damp" type="float" setter="" getter="get_total_linear_damp">
  209. The rate at which the body stops moving, if there are not any other forces moving it.
  210. </member>
  211. <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform">
  212. The body's transformation matrix.
  213. </member>
  214. </members>
  215. <constants>
  216. </constants>
  217. </class>