RigidBody.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="RigidBody" inherits="PhysicsBody" category="Core" version="3.0.alpha.custom_build">
  3. <brief_description>
  4. Physics Body whose position is determined through physics simulation in 3D space.
  5. </brief_description>
  6. <description>
  7. This is the node that implements full 3D physics. This means that you do not control a RigidBody directly. Instead you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
  8. This node can use custom force integration, for writing complex physics motion behavior per node.
  9. This node can shift state between regular Rigid body, Kinematic, Character or Static.
  10. Character mode forbids this node from being rotated.
  11. As a warning, don't change RigidBody's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop will yield strange behavior.
  12. </description>
  13. <tutorials>
  14. </tutorials>
  15. <demos>
  16. </demos>
  17. <methods>
  18. <method name="_integrate_forces" qualifiers="virtual">
  19. <return type="void">
  20. </return>
  21. <argument index="0" name="state" type="PhysicsDirectBodyState">
  22. </argument>
  23. <description>
  24. Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default it works in addition to the usual physics behavior, but [method set_use_custom_integrator] allows you to disable the default behavior and do fully custom force integration for a body.
  25. </description>
  26. </method>
  27. <method name="apply_impulse">
  28. <return type="void">
  29. </return>
  30. <argument index="0" name="position" type="Vector3">
  31. </argument>
  32. <argument index="1" name="impulse" type="Vector3">
  33. </argument>
  34. <description>
  35. Apply a positioned impulse (which will be affected by the body mass and shape). This is the equivalent of hitting a billiard ball with a cue: a force that is applied once, and only once. Both the impulse and the offset from the body origin are in global coordinates.
  36. </description>
  37. </method>
  38. <method name="get_angular_damp" qualifiers="const">
  39. <return type="float">
  40. </return>
  41. <description>
  42. Return the current body angular damp. Default is -1.
  43. </description>
  44. </method>
  45. <method name="get_angular_velocity" qualifiers="const">
  46. <return type="Vector3">
  47. </return>
  48. <description>
  49. Return the current body angular velocity.
  50. </description>
  51. </method>
  52. <method name="get_axis_lock" qualifiers="const">
  53. <return type="int" enum="RigidBody.AxisLock">
  54. </return>
  55. <description>
  56. Return the current axis lock of the body. One of AXIS_LOCK_* enum.
  57. </description>
  58. </method>
  59. <method name="get_bounce" qualifiers="const">
  60. <return type="float">
  61. </return>
  62. <description>
  63. Return the current body bounciness.
  64. </description>
  65. </method>
  66. <method name="get_colliding_bodies" qualifiers="const">
  67. <return type="Array">
  68. </return>
  69. <description>
  70. Return a list of the bodies colliding with this one. By default, number of max contacts reported is at 0 , see [method set_max_contacts_reported] to increase it.
  71. </description>
  72. </method>
  73. <method name="get_friction" qualifiers="const">
  74. <return type="float">
  75. </return>
  76. <description>
  77. Return the current body friction, from 0 (frictionless) to 1 (max friction).
  78. </description>
  79. </method>
  80. <method name="get_gravity_scale" qualifiers="const">
  81. <return type="float">
  82. </return>
  83. <description>
  84. Return the current body gravity scale.
  85. </description>
  86. </method>
  87. <method name="get_linear_damp" qualifiers="const">
  88. <return type="float">
  89. </return>
  90. <description>
  91. Return the current body linear damp. Default is -1.
  92. </description>
  93. </method>
  94. <method name="get_linear_velocity" qualifiers="const">
  95. <return type="Vector3">
  96. </return>
  97. <description>
  98. Return the current body linear velocity.
  99. </description>
  100. </method>
  101. <method name="get_mass" qualifiers="const">
  102. <return type="float">
  103. </return>
  104. <description>
  105. Return the current body mass.
  106. </description>
  107. </method>
  108. <method name="get_max_contacts_reported" qualifiers="const">
  109. <return type="int">
  110. </return>
  111. <description>
  112. Return the maximum contacts that can be reported. See [method set_max_contacts_reported].
  113. </description>
  114. </method>
  115. <method name="get_mode" qualifiers="const">
  116. <return type="int" enum="RigidBody.Mode">
  117. </return>
  118. <description>
  119. Return the current body mode, see [method set_mode].
  120. </description>
  121. </method>
  122. <method name="get_weight" qualifiers="const">
  123. <return type="float">
  124. </return>
  125. <description>
  126. Return the current body weight, given standard earth-weight (gravity 9.8).
  127. </description>
  128. </method>
  129. <method name="is_able_to_sleep" qualifiers="const">
  130. <return type="bool">
  131. </return>
  132. <description>
  133. Return whether the body has the ability to fall asleep when not moving. See [method set_can_sleep].
  134. </description>
  135. </method>
  136. <method name="is_contact_monitor_enabled" qualifiers="const">
  137. <return type="bool">
  138. </return>
  139. <description>
  140. Return whether contact monitoring is enabled.
  141. </description>
  142. </method>
  143. <method name="is_sleeping" qualifiers="const">
  144. <return type="bool">
  145. </return>
  146. <description>
  147. Return whether the body is sleeping.
  148. </description>
  149. </method>
  150. <method name="is_using_continuous_collision_detection" qualifiers="const">
  151. <return type="bool">
  152. </return>
  153. <description>
  154. Return whether this body is using continuous collision detection.
  155. </description>
  156. </method>
  157. <method name="is_using_custom_integrator">
  158. <return type="bool">
  159. </return>
  160. <description>
  161. Return whether the body is using a custom integrator.
  162. </description>
  163. </method>
  164. <method name="set_angular_damp">
  165. <return type="void">
  166. </return>
  167. <argument index="0" name="angular_damp" type="float">
  168. </argument>
  169. <description>
  170. Set the angular damp for this body. Default of -1, cannot be less than -1. If this value is different from -1, any angular damp derived from the world or areas will be overridden.
  171. </description>
  172. </method>
  173. <method name="set_angular_velocity">
  174. <return type="void">
  175. </return>
  176. <argument index="0" name="angular_velocity" type="Vector3">
  177. </argument>
  178. <description>
  179. Set the body angular velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may be running in another thread and definitely runs at a different granularity. Use [method _integrate_forces] as your process loop if you want to have precise control of the body state.
  180. </description>
  181. </method>
  182. <method name="set_axis_lock">
  183. <return type="void">
  184. </return>
  185. <argument index="0" name="axis_lock" type="int" enum="RigidBody.AxisLock">
  186. </argument>
  187. <description>
  188. Set the axis lock of the body, from the AXIS_LOCK_* enum. Axis lock stops the body from moving along the specified axis(X/Y/Z) and rotating along the other two axes.
  189. </description>
  190. </method>
  191. <method name="set_axis_velocity">
  192. <return type="void">
  193. </return>
  194. <argument index="0" name="axis_velocity" type="Vector3">
  195. </argument>
  196. <description>
  197. Set an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
  198. </description>
  199. </method>
  200. <method name="set_bounce">
  201. <return type="void">
  202. </return>
  203. <argument index="0" name="bounce" type="float">
  204. </argument>
  205. <description>
  206. Set the body bounciness, from 0 (no bounciness) to 1 (max bounciness).
  207. </description>
  208. </method>
  209. <method name="set_can_sleep">
  210. <return type="void">
  211. </return>
  212. <argument index="0" name="able_to_sleep" type="bool">
  213. </argument>
  214. <description>
  215. Set the body ability to fall asleep when not moving. This saves an enormous amount of processor time when there are plenty of rigid bodies (non static) in a scene.
  216. Sleeping bodies are not affected by forces until a collision or an [method apply_impulse] / [method set_applied_force] wakes them up. Until then, they behave like a static body.
  217. </description>
  218. </method>
  219. <method name="set_contact_monitor">
  220. <return type="void">
  221. </return>
  222. <argument index="0" name="enabled" type="bool">
  223. </argument>
  224. <description>
  225. Enable contact monitoring. This allows the body to emit signals when it collides with another.
  226. </description>
  227. </method>
  228. <method name="set_friction">
  229. <return type="void">
  230. </return>
  231. <argument index="0" name="friction" type="float">
  232. </argument>
  233. <description>
  234. Set the body friction, from 0 (frictionless) to 1 (max friction).
  235. </description>
  236. </method>
  237. <method name="set_gravity_scale">
  238. <return type="void">
  239. </return>
  240. <argument index="0" name="gravity_scale" type="float">
  241. </argument>
  242. <description>
  243. Set the gravity factor. This factor multiplies gravity intensity just for this body.
  244. </description>
  245. </method>
  246. <method name="set_linear_damp">
  247. <return type="void">
  248. </return>
  249. <argument index="0" name="linear_damp" type="float">
  250. </argument>
  251. <description>
  252. Set the linear damp for this body. Default of -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.
  253. </description>
  254. </method>
  255. <method name="set_linear_velocity">
  256. <return type="void">
  257. </return>
  258. <argument index="0" name="linear_velocity" type="Vector3">
  259. </argument>
  260. <description>
  261. Set the body linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may be running in another thread and definitely runs at a different granularity. Use [method _integrate_forces] as your process loop if you want to have precise control of the body state.
  262. </description>
  263. </method>
  264. <method name="set_mass">
  265. <return type="void">
  266. </return>
  267. <argument index="0" name="mass" type="float">
  268. </argument>
  269. <description>
  270. Set the body mass.
  271. </description>
  272. </method>
  273. <method name="set_max_contacts_reported">
  274. <return type="void">
  275. </return>
  276. <argument index="0" name="amount" type="int">
  277. </argument>
  278. <description>
  279. Set the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
  280. </description>
  281. </method>
  282. <method name="set_mode">
  283. <return type="void">
  284. </return>
  285. <argument index="0" name="mode" type="int" enum="RigidBody.Mode">
  286. </argument>
  287. <description>
  288. Set the body mode, from the MODE_* enum. This allows to change to a static body or a character body.
  289. </description>
  290. </method>
  291. <method name="set_sleeping">
  292. <return type="void">
  293. </return>
  294. <argument index="0" name="sleeping" type="bool">
  295. </argument>
  296. <description>
  297. Set whether a body is sleeping or not. Sleeping bodies are not affected by forces until a collision or an [method apply_impulse] wakes them up. Until then, they behave like a static body.
  298. </description>
  299. </method>
  300. <method name="set_use_continuous_collision_detection">
  301. <return type="void">
  302. </return>
  303. <argument index="0" name="enable" type="bool">
  304. </argument>
  305. <description>
  306. Set the continuous collision detection mode from the enum CCD_MODE_*.
  307. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. The first is more precise, and misses less impacts by small, fast-moving objects. The second is faster to compute, but can miss small, fast-moving objects.
  308. </description>
  309. </method>
  310. <method name="set_use_custom_integrator">
  311. <return type="void">
  312. </return>
  313. <argument index="0" name="enable" type="bool">
  314. </argument>
  315. <description>
  316. Pass true to disable the internal force integration (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined.
  317. </description>
  318. </method>
  319. <method name="set_weight">
  320. <return type="void">
  321. </return>
  322. <argument index="0" name="weight" type="float">
  323. </argument>
  324. <description>
  325. Set the body weight given standard earth-weight (gravity 9.8).
  326. </description>
  327. </method>
  328. </methods>
  329. <members>
  330. <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp">
  331. Damps RigidBody's rotational forces.
  332. </member>
  333. <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity">
  334. RigidBody's rotational velocity.
  335. </member>
  336. <member name="axis_lock" type="int" setter="set_axis_lock" getter="get_axis_lock" enum="RigidBody.AxisLock">
  337. Locks the rotational forces to a particular axis, preventing rotations on other axes.
  338. </member>
  339. <member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
  340. RigidBody's bounciness.
  341. </member>
  342. <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep">
  343. If [code]true[/code] the RigidBody will not calculate forces and will act as a static body while there is no movement. It will wake up when forces are applied through other collisions or when the [code]apply_impulse[/code] method is used.
  344. </member>
  345. <member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled">
  346. If true, the RigidBody will emit signals when it collides with another RigidBody.
  347. </member>
  348. <member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported">
  349. The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
  350. </member>
  351. <member name="continuous_cd" type="bool" setter="set_use_continuous_collision_detection" getter="is_using_continuous_collision_detection">
  352. If [code]true[/code] continuous collision detection is used.
  353. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses less impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects.
  354. </member>
  355. <member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator">
  356. If [code]true[/code] internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined.
  357. </member>
  358. <member name="friction" type="float" setter="set_friction" getter="get_friction">
  359. The body friction, from 0 (frictionless) to 1 (max friction).
  360. </member>
  361. <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale">
  362. This is multiplied by the global 3D gravity setting found in "Project &gt; Project Settings &gt; Physics &gt; 3d" to produce RigidBody's gravity. E.g. a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
  363. </member>
  364. <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp">
  365. RigidBody's linear damp. Default value: -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.
  366. </member>
  367. <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity">
  368. RigidBody's linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
  369. </member>
  370. <member name="mass" type="float" setter="set_mass" getter="get_mass">
  371. RigidBody's mass.
  372. </member>
  373. <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody.Mode">
  374. The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER.
  375. </member>
  376. <member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping">
  377. If [code]true[/code] RigidBody is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method.
  378. </member>
  379. <member name="weight" type="float" setter="set_weight" getter="get_weight">
  380. RigidBody's weight based on its mass and the global 3D gravity. Global values are set in "Project &gt; Project Settings &gt; Physics &gt; 3d".
  381. </member>
  382. </members>
  383. <signals>
  384. <signal name="body_entered">
  385. <argument index="0" name="body" type="Object">
  386. </argument>
  387. <description>
  388. Emitted when a body enters into contact with this one. Contact monitor and contacts reported must be enabled for this to work.
  389. </description>
  390. </signal>
  391. <signal name="body_exited">
  392. <argument index="0" name="body" type="Object">
  393. </argument>
  394. <description>
  395. Emitted when a body shape exits contact with this one. Contact monitor and contacts reported must be enabled for this to work.
  396. </description>
  397. </signal>
  398. <signal name="body_shape_entered">
  399. <argument index="0" name="body_id" type="int">
  400. </argument>
  401. <argument index="1" name="body" type="Object">
  402. </argument>
  403. <argument index="2" name="body_shape" type="int">
  404. </argument>
  405. <argument index="3" name="local_shape" type="int">
  406. </argument>
  407. <description>
  408. Emitted when a body enters into contact with this one. Contact monitor and contacts reported must be enabled for this to work.
  409. This signal not only receives the body that collided with this one, but also its [RID] (body_id), the shape index from the colliding body (body_shape), and the shape index from this body (local_shape) the other body collided with.
  410. </description>
  411. </signal>
  412. <signal name="body_shape_exited">
  413. <argument index="0" name="body_id" type="int">
  414. </argument>
  415. <argument index="1" name="body" type="Object">
  416. </argument>
  417. <argument index="2" name="body_shape" type="int">
  418. </argument>
  419. <argument index="3" name="local_shape" type="int">
  420. </argument>
  421. <description>
  422. Emitted when a body shape exits contact with this one. Contact monitor and contacts reported must be enabled for this to work.
  423. This signal not only receives the body that stopped colliding with this one, but also its [RID] (body_id), the shape index from the colliding body (body_shape), and the shape index from this body (local_shape) the other body stopped colliding with.
  424. </description>
  425. </signal>
  426. <signal name="sleeping_state_changed">
  427. <description>
  428. Emitted when the body changes its sleeping state. Either by sleeping or waking up.
  429. </description>
  430. </signal>
  431. </signals>
  432. <constants>
  433. <constant name="MODE_RIGID" value="0">
  434. Rigid body. This is the "natural" state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code.
  435. </constant>
  436. <constant name="MODE_STATIC" value="1">
  437. Static mode. The body behaves like a [StaticBody], and can only move by user code.
  438. </constant>
  439. <constant name="MODE_CHARACTER" value="2">
  440. Character body. This behaves like a rigid body, but can not rotate.
  441. </constant>
  442. <constant name="MODE_KINEMATIC" value="3">
  443. Kinematic body. The body behaves like a [KinematicBody], and can only move by user code.
  444. </constant>
  445. <constant name="AXIS_LOCK_DISABLED" value="0">
  446. </constant>
  447. <constant name="AXIS_LOCK_X" value="1">
  448. </constant>
  449. <constant name="AXIS_LOCK_Y" value="2">
  450. </constant>
  451. <constant name="AXIS_LOCK_Z" value="3">
  452. </constant>
  453. </constants>
  454. </class>