2
0

class_rigidbody.rst 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the RigidBody.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_RigidBody:
  5. RigidBody
  6. =========
  7. **Inherits:** :ref:`PhysicsBody<class_physicsbody>` **<** :ref:`CollisionObject<class_collisionobject>` **<** :ref:`Spatial<class_spatial>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Physics Body whose position is determined through physics simulation in 3D space.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`_integrate_forces<class_RigidBody__integrate_forces>` **(** :ref:`PhysicsDirectBodyState<class_physicsdirectbodystate>` state **)** virtual |
  16. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`apply_impulse<class_RigidBody_apply_impulse>` **(** :ref:`Vector3<class_vector3>` position, :ref:`Vector3<class_vector3>` impulse **)** |
  18. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`float<class_float>` | :ref:`get_angular_damp<class_RigidBody_get_angular_damp>` **(** **)** const |
  20. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Vector3<class_vector3>` | :ref:`get_angular_velocity<class_RigidBody_get_angular_velocity>` **(** **)** const |
  22. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_axis_lock<class_RigidBody_get_axis_lock>` **(** **)** const |
  24. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`get_bounce<class_RigidBody_get_bounce>` **(** **)** const |
  26. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Array<class_array>` | :ref:`get_colliding_bodies<class_RigidBody_get_colliding_bodies>` **(** **)** const |
  28. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`float<class_float>` | :ref:`get_friction<class_RigidBody_get_friction>` **(** **)** const |
  30. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`get_gravity_scale<class_RigidBody_get_gravity_scale>` **(** **)** const |
  32. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`get_linear_damp<class_RigidBody_get_linear_damp>` **(** **)** const |
  34. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Vector3<class_vector3>` | :ref:`get_linear_velocity<class_RigidBody_get_linear_velocity>` **(** **)** const |
  36. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`float<class_float>` | :ref:`get_mass<class_RigidBody_get_mass>` **(** **)** const |
  38. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`get_max_contacts_reported<class_RigidBody_get_max_contacts_reported>` **(** **)** const |
  40. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`get_mode<class_RigidBody_get_mode>` **(** **)** const |
  42. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`float<class_float>` | :ref:`get_weight<class_RigidBody_get_weight>` **(** **)** const |
  44. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`is_able_to_sleep<class_RigidBody_is_able_to_sleep>` **(** **)** const |
  46. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`is_contact_monitor_enabled<class_RigidBody_is_contact_monitor_enabled>` **(** **)** const |
  48. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`is_sleeping<class_RigidBody_is_sleeping>` **(** **)** const |
  50. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`bool<class_bool>` | :ref:`is_using_continuous_collision_detection<class_RigidBody_is_using_continuous_collision_detection>` **(** **)** const |
  52. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`is_using_custom_integrator<class_RigidBody_is_using_custom_integrator>` **(** **)** |
  54. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_angular_damp<class_RigidBody_set_angular_damp>` **(** :ref:`float<class_float>` angular_damp **)** |
  56. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_angular_velocity<class_RigidBody_set_angular_velocity>` **(** :ref:`Vector3<class_vector3>` angular_velocity **)** |
  58. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`set_axis_lock<class_RigidBody_set_axis_lock>` **(** :ref:`int<class_int>` axis_lock **)** |
  60. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_axis_velocity<class_RigidBody_set_axis_velocity>` **(** :ref:`Vector3<class_vector3>` axis_velocity **)** |
  62. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_bounce<class_RigidBody_set_bounce>` **(** :ref:`float<class_float>` bounce **)** |
  64. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`set_can_sleep<class_RigidBody_set_can_sleep>` **(** :ref:`bool<class_bool>` able_to_sleep **)** |
  66. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_contact_monitor<class_RigidBody_set_contact_monitor>` **(** :ref:`bool<class_bool>` enabled **)** |
  68. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`set_friction<class_RigidBody_set_friction>` **(** :ref:`float<class_float>` friction **)** |
  70. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`set_gravity_scale<class_RigidBody_set_gravity_scale>` **(** :ref:`float<class_float>` gravity_scale **)** |
  72. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`set_linear_damp<class_RigidBody_set_linear_damp>` **(** :ref:`float<class_float>` linear_damp **)** |
  74. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`set_linear_velocity<class_RigidBody_set_linear_velocity>` **(** :ref:`Vector3<class_vector3>` linear_velocity **)** |
  76. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`set_mass<class_RigidBody_set_mass>` **(** :ref:`float<class_float>` mass **)** |
  78. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`set_max_contacts_reported<class_RigidBody_set_max_contacts_reported>` **(** :ref:`int<class_int>` amount **)** |
  80. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`set_mode<class_RigidBody_set_mode>` **(** :ref:`int<class_int>` mode **)** |
  82. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`set_sleeping<class_RigidBody_set_sleeping>` **(** :ref:`bool<class_bool>` sleeping **)** |
  84. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`set_use_continuous_collision_detection<class_RigidBody_set_use_continuous_collision_detection>` **(** :ref:`bool<class_bool>` enable **)** |
  86. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`set_use_custom_integrator<class_RigidBody_set_use_custom_integrator>` **(** :ref:`bool<class_bool>` enable **)** |
  88. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`set_weight<class_RigidBody_set_weight>` **(** :ref:`float<class_float>` weight **)** |
  90. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
  91. Signals
  92. -------
  93. .. _class_RigidBody_body_entered:
  94. - **body_entered** **(** :ref:`Object<class_object>` body **)**
  95. Emitted when a body enters into contact with this one. Contact monitor and contacts reported must be enabled for this to work.
  96. .. _class_RigidBody_body_exited:
  97. - **body_exited** **(** :ref:`Object<class_object>` body **)**
  98. Emitted when a body shape exits contact with this one. Contact monitor and contacts reported must be enabled for this to work.
  99. .. _class_RigidBody_body_shape_entered:
  100. - **body_shape_entered** **(** :ref:`int<class_int>` body_id, :ref:`Object<class_object>` body, :ref:`int<class_int>` body_shape, :ref:`int<class_int>` local_shape **)**
  101. Emitted when a body enters into contact with this one. Contact monitor and contacts reported must be enabled for this to work.
  102. This signal not only receives the body that collided with this one, but also its :ref:`RID<class_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.
  103. .. _class_RigidBody_body_shape_exited:
  104. - **body_shape_exited** **(** :ref:`int<class_int>` body_id, :ref:`Object<class_object>` body, :ref:`int<class_int>` body_shape, :ref:`int<class_int>` local_shape **)**
  105. Emitted when a body shape exits contact with this one. Contact monitor and contacts reported must be enabled for this to work.
  106. This signal not only receives the body that stopped colliding with this one, but also its :ref:`RID<class_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.
  107. .. _class_RigidBody_sleeping_state_changed:
  108. - **sleeping_state_changed** **(** **)**
  109. Emitted when the body changes its sleeping state. Either by sleeping or waking up.
  110. Member Variables
  111. ----------------
  112. .. _class_RigidBody_angular_damp:
  113. - :ref:`float<class_float>` **angular_damp** - Damps RigidBody's rotational forces.
  114. .. _class_RigidBody_angular_velocity:
  115. - :ref:`Vector3<class_vector3>` **angular_velocity** - RigidBody's rotational velocity.
  116. .. _class_RigidBody_axis_lock:
  117. - :ref:`int<class_int>` **axis_lock** - Locks the rotational forces to a particular axis, preventing rotations on other axes.
  118. .. _class_RigidBody_bounce:
  119. - :ref:`float<class_float>` **bounce** - RigidBody's bounciness.
  120. .. _class_RigidBody_can_sleep:
  121. - :ref:`bool<class_bool>` **can_sleep** - If ``true`` 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 ``apply_impulse`` method is used.
  122. .. _class_RigidBody_contact_monitor:
  123. - :ref:`bool<class_bool>` **contact_monitor** - If true, the RigidBody will emit signals when it collides with another RigidBody.
  124. .. _class_RigidBody_contacts_reported:
  125. - :ref:`int<class_int>` **contacts_reported** - 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.
  126. .. _class_RigidBody_continuous_cd:
  127. - :ref:`bool<class_bool>` **continuous_cd** - If ``true`` continuous collision detection is used.
  128. 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.
  129. .. _class_RigidBody_custom_integrator:
  130. - :ref:`bool<class_bool>` **custom_integrator** - If ``true`` 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 :ref:`_integrate_forces<class_RigidBody__integrate_forces>` function, if defined.
  131. .. _class_RigidBody_friction:
  132. - :ref:`float<class_float>` **friction** - The body friction, from 0 (frictionless) to 1 (max friction).
  133. .. _class_RigidBody_gravity_scale:
  134. - :ref:`float<class_float>` **gravity_scale** - This is multiplied by the global 3D gravity setting found in "Project > Project Settings > Physics > 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.
  135. .. _class_RigidBody_linear_damp:
  136. - :ref:`float<class_float>` **linear_damp** - 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.
  137. .. _class_RigidBody_linear_velocity:
  138. - :ref:`Vector3<class_vector3>` **linear_velocity** - RigidBody's linear velocity. Can be used sporadically, but **DON'T SET THIS IN EVERY FRAME**, because physics may run in another thread and runs at a different granularity. Use :ref:`_integrate_forces<class_RigidBody__integrate_forces>` as your process loop for precise control of the body state.
  139. .. _class_RigidBody_mass:
  140. - :ref:`float<class_float>` **mass** - RigidBody's mass.
  141. .. _class_RigidBody_mode:
  142. - :ref:`int<class_int>` **mode** - The body mode from the MODE\_\* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER.
  143. .. _class_RigidBody_sleeping:
  144. - :ref:`bool<class_bool>` **sleeping** - If ``true`` RigidBody is sleeping and will not calculate forces until woken up by a collision or the ``apply_impulse`` method.
  145. .. _class_RigidBody_weight:
  146. - :ref:`float<class_float>` **weight** - RigidBody's weight based on its mass and the global 3D gravity. Global values are set in "Project > Project Settings > Physics > 3d".
  147. Numeric Constants
  148. -----------------
  149. - **MODE_RIGID** = **0** --- 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.
  150. - **MODE_STATIC** = **1** --- Static mode. The body behaves like a :ref:`StaticBody<class_staticbody>`, and can only move by user code.
  151. - **MODE_CHARACTER** = **2** --- Character body. This behaves like a rigid body, but can not rotate.
  152. - **MODE_KINEMATIC** = **3** --- Kinematic body. The body behaves like a :ref:`KinematicBody<class_kinematicbody>`, and can only move by user code.
  153. - **AXIS_LOCK_DISABLED** = **0**
  154. - **AXIS_LOCK_X** = **1**
  155. - **AXIS_LOCK_Y** = **2**
  156. - **AXIS_LOCK_Z** = **3**
  157. Description
  158. -----------
  159. 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.
  160. This node can use custom force integration, for writing complex physics motion behavior per node.
  161. This node can shift state between regular Rigid body, Kinematic, Character or Static.
  162. Character mode forbids this node from being rotated.
  163. 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.
  164. Member Function Description
  165. ---------------------------
  166. .. _class_RigidBody__integrate_forces:
  167. - void **_integrate_forces** **(** :ref:`PhysicsDirectBodyState<class_physicsdirectbodystate>` state **)** virtual
  168. 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 :ref:`set_use_custom_integrator<class_RigidBody_set_use_custom_integrator>` allows you to disable the default behavior and do fully custom force integration for a body.
  169. .. _class_RigidBody_apply_impulse:
  170. - void **apply_impulse** **(** :ref:`Vector3<class_vector3>` position, :ref:`Vector3<class_vector3>` impulse **)**
  171. 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.
  172. .. _class_RigidBody_get_angular_damp:
  173. - :ref:`float<class_float>` **get_angular_damp** **(** **)** const
  174. Return the current body angular damp. Default is -1.
  175. .. _class_RigidBody_get_angular_velocity:
  176. - :ref:`Vector3<class_vector3>` **get_angular_velocity** **(** **)** const
  177. Return the current body angular velocity.
  178. .. _class_RigidBody_get_axis_lock:
  179. - :ref:`int<class_int>` **get_axis_lock** **(** **)** const
  180. Return the current axis lock of the body. One of AXIS_LOCK\_\* enum.
  181. .. _class_RigidBody_get_bounce:
  182. - :ref:`float<class_float>` **get_bounce** **(** **)** const
  183. Return the current body bounciness.
  184. .. _class_RigidBody_get_colliding_bodies:
  185. - :ref:`Array<class_array>` **get_colliding_bodies** **(** **)** const
  186. Return a list of the bodies colliding with this one. By default, number of max contacts reported is at 0 , see :ref:`set_max_contacts_reported<class_RigidBody_set_max_contacts_reported>` to increase it.
  187. .. _class_RigidBody_get_friction:
  188. - :ref:`float<class_float>` **get_friction** **(** **)** const
  189. Return the current body friction, from 0 (frictionless) to 1 (max friction).
  190. .. _class_RigidBody_get_gravity_scale:
  191. - :ref:`float<class_float>` **get_gravity_scale** **(** **)** const
  192. Return the current body gravity scale.
  193. .. _class_RigidBody_get_linear_damp:
  194. - :ref:`float<class_float>` **get_linear_damp** **(** **)** const
  195. Return the current body linear damp. Default is -1.
  196. .. _class_RigidBody_get_linear_velocity:
  197. - :ref:`Vector3<class_vector3>` **get_linear_velocity** **(** **)** const
  198. Return the current body linear velocity.
  199. .. _class_RigidBody_get_mass:
  200. - :ref:`float<class_float>` **get_mass** **(** **)** const
  201. Return the current body mass.
  202. .. _class_RigidBody_get_max_contacts_reported:
  203. - :ref:`int<class_int>` **get_max_contacts_reported** **(** **)** const
  204. Return the maximum contacts that can be reported. See :ref:`set_max_contacts_reported<class_RigidBody_set_max_contacts_reported>`.
  205. .. _class_RigidBody_get_mode:
  206. - :ref:`int<class_int>` **get_mode** **(** **)** const
  207. Return the current body mode, see :ref:`set_mode<class_RigidBody_set_mode>`.
  208. .. _class_RigidBody_get_weight:
  209. - :ref:`float<class_float>` **get_weight** **(** **)** const
  210. Return the current body weight, given standard earth-weight (gravity 9.8).
  211. .. _class_RigidBody_is_able_to_sleep:
  212. - :ref:`bool<class_bool>` **is_able_to_sleep** **(** **)** const
  213. Return whether the body has the ability to fall asleep when not moving. See :ref:`set_can_sleep<class_RigidBody_set_can_sleep>`.
  214. .. _class_RigidBody_is_contact_monitor_enabled:
  215. - :ref:`bool<class_bool>` **is_contact_monitor_enabled** **(** **)** const
  216. Return whether contact monitoring is enabled.
  217. .. _class_RigidBody_is_sleeping:
  218. - :ref:`bool<class_bool>` **is_sleeping** **(** **)** const
  219. Return whether the body is sleeping.
  220. .. _class_RigidBody_is_using_continuous_collision_detection:
  221. - :ref:`bool<class_bool>` **is_using_continuous_collision_detection** **(** **)** const
  222. Return whether this body is using continuous collision detection.
  223. .. _class_RigidBody_is_using_custom_integrator:
  224. - :ref:`bool<class_bool>` **is_using_custom_integrator** **(** **)**
  225. Return whether the body is using a custom integrator.
  226. .. _class_RigidBody_set_angular_damp:
  227. - void **set_angular_damp** **(** :ref:`float<class_float>` angular_damp **)**
  228. 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.
  229. .. _class_RigidBody_set_angular_velocity:
  230. - void **set_angular_velocity** **(** :ref:`Vector3<class_vector3>` angular_velocity **)**
  231. Set the body angular velocity. Can be used sporadically, but **DON'T SET THIS IN EVERY FRAME**, because physics may be running in another thread and definitely runs at a different granularity. Use :ref:`_integrate_forces<class_RigidBody__integrate_forces>` as your process loop if you want to have precise control of the body state.
  232. .. _class_RigidBody_set_axis_lock:
  233. - void **set_axis_lock** **(** :ref:`int<class_int>` axis_lock **)**
  234. 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.
  235. .. _class_RigidBody_set_axis_velocity:
  236. - void **set_axis_velocity** **(** :ref:`Vector3<class_vector3>` axis_velocity **)**
  237. 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.
  238. .. _class_RigidBody_set_bounce:
  239. - void **set_bounce** **(** :ref:`float<class_float>` bounce **)**
  240. Set the body bounciness, from 0 (no bounciness) to 1 (max bounciness).
  241. .. _class_RigidBody_set_can_sleep:
  242. - void **set_can_sleep** **(** :ref:`bool<class_bool>` able_to_sleep **)**
  243. 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.
  244. Sleeping bodies are not affected by forces until a collision or an :ref:`apply_impulse<class_RigidBody_apply_impulse>` / :ref:`set_applied_force<class_RigidBody_set_applied_force>` wakes them up. Until then, they behave like a static body.
  245. .. _class_RigidBody_set_contact_monitor:
  246. - void **set_contact_monitor** **(** :ref:`bool<class_bool>` enabled **)**
  247. Enable contact monitoring. This allows the body to emit signals when it collides with another.
  248. .. _class_RigidBody_set_friction:
  249. - void **set_friction** **(** :ref:`float<class_float>` friction **)**
  250. Set the body friction, from 0 (frictionless) to 1 (max friction).
  251. .. _class_RigidBody_set_gravity_scale:
  252. - void **set_gravity_scale** **(** :ref:`float<class_float>` gravity_scale **)**
  253. Set the gravity factor. This factor multiplies gravity intensity just for this body.
  254. .. _class_RigidBody_set_linear_damp:
  255. - void **set_linear_damp** **(** :ref:`float<class_float>` linear_damp **)**
  256. 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.
  257. .. _class_RigidBody_set_linear_velocity:
  258. - void **set_linear_velocity** **(** :ref:`Vector3<class_vector3>` linear_velocity **)**
  259. Set the body linear velocity. Can be used sporadically, but **DON'T SET THIS IN EVERY FRAME**, because physics may be running in another thread and definitely runs at a different granularity. Use :ref:`_integrate_forces<class_RigidBody__integrate_forces>` as your process loop if you want to have precise control of the body state.
  260. .. _class_RigidBody_set_mass:
  261. - void **set_mass** **(** :ref:`float<class_float>` mass **)**
  262. Set the body mass.
  263. .. _class_RigidBody_set_max_contacts_reported:
  264. - void **set_max_contacts_reported** **(** :ref:`int<class_int>` amount **)**
  265. 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.
  266. .. _class_RigidBody_set_mode:
  267. - void **set_mode** **(** :ref:`int<class_int>` mode **)**
  268. Set the body mode, from the MODE\_\* enum. This allows to change to a static body or a character body.
  269. .. _class_RigidBody_set_sleeping:
  270. - void **set_sleeping** **(** :ref:`bool<class_bool>` sleeping **)**
  271. Set whether a body is sleeping or not. Sleeping bodies are not affected by forces until a collision or an :ref:`apply_impulse<class_RigidBody_apply_impulse>` wakes them up. Until then, they behave like a static body.
  272. .. _class_RigidBody_set_use_continuous_collision_detection:
  273. - void **set_use_continuous_collision_detection** **(** :ref:`bool<class_bool>` enable **)**
  274. Set the continuous collision detection mode from the enum CCD_MODE\_\*.
  275. 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.
  276. .. _class_RigidBody_set_use_custom_integrator:
  277. - void **set_use_custom_integrator** **(** :ref:`bool<class_bool>` enable **)**
  278. 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 :ref:`_integrate_forces<class_RigidBody__integrate_forces>` function, if defined.
  279. .. _class_RigidBody_set_weight:
  280. - void **set_weight** **(** :ref:`float<class_float>` weight **)**
  281. Set the body weight given standard earth-weight (gravity 9.8).