class_softbody.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/SoftBody.xml.
  6. .. _class_SoftBody:
  7. SoftBody
  8. ========
  9. **Inherits:** :ref:`MeshInstance<class_MeshInstance>` **<** :ref:`GeometryInstance<class_GeometryInstance>` **<** :ref:`VisualInstance<class_VisualInstance>` **<** :ref:`CullInstance<class_CullInstance>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A soft mesh physics body.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A deformable physics body. Used to create elastic or deformable objects such as cloth, rubber, or other flexible materials.
  15. \ **Note:** There are many known bugs in **SoftBody**. Therefore, it's not recommended to use them for things that can affect gameplay (such as a player character made entirely out of soft bodies).
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`../tutorials/physics/soft_body`
  20. .. rst-class:: classref-reftable-group
  21. Properties
  22. ----------
  23. .. table::
  24. :widths: auto
  25. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  26. | :ref:`float<class_float>` | :ref:`areaAngular_stiffness<class_SoftBody_property_areaAngular_stiffness>` | ``0.5`` |
  27. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  28. | :ref:`int<class_int>` | :ref:`collision_layer<class_SoftBody_property_collision_layer>` | ``1`` |
  29. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  30. | :ref:`int<class_int>` | :ref:`collision_mask<class_SoftBody_property_collision_mask>` | ``1`` |
  31. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  32. | :ref:`float<class_float>` | :ref:`damping_coefficient<class_SoftBody_property_damping_coefficient>` | ``0.01`` |
  33. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  34. | :ref:`float<class_float>` | :ref:`drag_coefficient<class_SoftBody_property_drag_coefficient>` | ``0.0`` |
  35. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  36. | :ref:`float<class_float>` | :ref:`linear_stiffness<class_SoftBody_property_linear_stiffness>` | ``0.5`` |
  37. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  38. | :ref:`NodePath<class_NodePath>` | :ref:`parent_collision_ignore<class_SoftBody_property_parent_collision_ignore>` | ``NodePath("")`` |
  39. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  40. | :ref:`bool<class_bool>` | :ref:`physics_enabled<class_SoftBody_property_physics_enabled>` | ``true`` |
  41. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  42. | :ref:`float<class_float>` | :ref:`pose_matching_coefficient<class_SoftBody_property_pose_matching_coefficient>` | ``0.0`` |
  43. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  44. | :ref:`float<class_float>` | :ref:`pressure_coefficient<class_SoftBody_property_pressure_coefficient>` | ``0.0`` |
  45. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  46. | :ref:`bool<class_bool>` | :ref:`ray_pickable<class_SoftBody_property_ray_pickable>` | ``true`` |
  47. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  48. | :ref:`int<class_int>` | :ref:`simulation_precision<class_SoftBody_property_simulation_precision>` | ``5`` |
  49. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  50. | :ref:`float<class_float>` | :ref:`total_mass<class_SoftBody_property_total_mass>` | ``1.0`` |
  51. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  52. | :ref:`float<class_float>` | :ref:`volume_stiffness<class_SoftBody_property_volume_stiffness>` | ``0.5`` |
  53. +---------------------------------+-------------------------------------------------------------------------------------+------------------+
  54. .. rst-class:: classref-reftable-group
  55. Methods
  56. -------
  57. .. table::
  58. :widths: auto
  59. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`add_collision_exception_with<class_SoftBody_method_add_collision_exception_with>` **(** :ref:`Node<class_Node>` body **)** |
  61. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Array<class_Array>` | :ref:`get_collision_exceptions<class_SoftBody_method_get_collision_exceptions>` **(** **)** |
  63. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_bit<class_SoftBody_method_get_collision_layer_bit>` **(** :ref:`int<class_int>` bit **)** |const| |
  65. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_bit<class_SoftBody_method_get_collision_mask_bit>` **(** :ref:`int<class_int>` bit **)** |const| |
  67. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`Vector3<class_Vector3>` | :ref:`get_point_transform<class_SoftBody_method_get_point_transform>` **(** :ref:`int<class_int>` point_index **)** |
  69. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`is_point_pinned<class_SoftBody_method_is_point_pinned>` **(** :ref:`int<class_int>` point_index **)** |const| |
  71. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`remove_collision_exception_with<class_SoftBody_method_remove_collision_exception_with>` **(** :ref:`Node<class_Node>` body **)** |
  73. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`set_collision_layer_bit<class_SoftBody_method_set_collision_layer_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  75. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`set_collision_mask_bit<class_SoftBody_method_set_collision_mask_bit>` **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)** |
  77. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`set_point_pinned<class_SoftBody_method_set_point_pinned>` **(** :ref:`int<class_int>` point_index, :ref:`bool<class_bool>` pinned, :ref:`NodePath<class_NodePath>` attachment_path=NodePath("") **)** |
  79. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. .. rst-class:: classref-section-separator
  81. ----
  82. .. rst-class:: classref-descriptions-group
  83. Property Descriptions
  84. ---------------------
  85. .. _class_SoftBody_property_areaAngular_stiffness:
  86. .. rst-class:: classref-property
  87. :ref:`float<class_float>` **areaAngular_stiffness** = ``0.5``
  88. .. rst-class:: classref-property-setget
  89. - void **set_areaAngular_stiffness** **(** :ref:`float<class_float>` value **)**
  90. - :ref:`float<class_float>` **get_areaAngular_stiffness** **(** **)**
  91. .. container:: contribute
  92. There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_SoftBody_property_collision_layer:
  96. .. rst-class:: classref-property
  97. :ref:`int<class_int>` **collision_layer** = ``1``
  98. .. rst-class:: classref-property-setget
  99. - void **set_collision_layer** **(** :ref:`int<class_int>` value **)**
  100. - :ref:`int<class_int>` **get_collision_layer** **(** **)**
  101. The physics layers this SoftBody is in.
  102. Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
  103. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_SoftBody_property_collision_mask:
  107. .. rst-class:: classref-property
  108. :ref:`int<class_int>` **collision_mask** = ``1``
  109. .. rst-class:: classref-property-setget
  110. - void **set_collision_mask** **(** :ref:`int<class_int>` value **)**
  111. - :ref:`int<class_int>` **get_collision_mask** **(** **)**
  112. The physics layers this SoftBody scans for collisions. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_SoftBody_property_damping_coefficient:
  116. .. rst-class:: classref-property
  117. :ref:`float<class_float>` **damping_coefficient** = ``0.01``
  118. .. rst-class:: classref-property-setget
  119. - void **set_damping_coefficient** **(** :ref:`float<class_float>` value **)**
  120. - :ref:`float<class_float>` **get_damping_coefficient** **(** **)**
  121. .. container:: contribute
  122. There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_SoftBody_property_drag_coefficient:
  126. .. rst-class:: classref-property
  127. :ref:`float<class_float>` **drag_coefficient** = ``0.0``
  128. .. rst-class:: classref-property-setget
  129. - void **set_drag_coefficient** **(** :ref:`float<class_float>` value **)**
  130. - :ref:`float<class_float>` **get_drag_coefficient** **(** **)**
  131. .. container:: contribute
  132. There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_SoftBody_property_linear_stiffness:
  136. .. rst-class:: classref-property
  137. :ref:`float<class_float>` **linear_stiffness** = ``0.5``
  138. .. rst-class:: classref-property-setget
  139. - void **set_linear_stiffness** **(** :ref:`float<class_float>` value **)**
  140. - :ref:`float<class_float>` **get_linear_stiffness** **(** **)**
  141. .. container:: contribute
  142. There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_SoftBody_property_parent_collision_ignore:
  146. .. rst-class:: classref-property
  147. :ref:`NodePath<class_NodePath>` **parent_collision_ignore** = ``NodePath("")``
  148. .. rst-class:: classref-property-setget
  149. - void **set_parent_collision_ignore** **(** :ref:`NodePath<class_NodePath>` value **)**
  150. - :ref:`NodePath<class_NodePath>` **get_parent_collision_ignore** **(** **)**
  151. :ref:`NodePath<class_NodePath>` to a :ref:`CollisionObject<class_CollisionObject>` this SoftBody should avoid clipping.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_SoftBody_property_physics_enabled:
  155. .. rst-class:: classref-property
  156. :ref:`bool<class_bool>` **physics_enabled** = ``true``
  157. .. rst-class:: classref-property-setget
  158. - void **set_physics_enabled** **(** :ref:`bool<class_bool>` value **)**
  159. - :ref:`bool<class_bool>` **is_physics_enabled** **(** **)**
  160. If ``true``, the **SoftBody** is simulated in physics. Can be set to ``false`` to pause the physics simulation.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_SoftBody_property_pose_matching_coefficient:
  164. .. rst-class:: classref-property
  165. :ref:`float<class_float>` **pose_matching_coefficient** = ``0.0``
  166. .. rst-class:: classref-property-setget
  167. - void **set_pose_matching_coefficient** **(** :ref:`float<class_float>` value **)**
  168. - :ref:`float<class_float>` **get_pose_matching_coefficient** **(** **)**
  169. .. container:: contribute
  170. There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  171. .. rst-class:: classref-item-separator
  172. ----
  173. .. _class_SoftBody_property_pressure_coefficient:
  174. .. rst-class:: classref-property
  175. :ref:`float<class_float>` **pressure_coefficient** = ``0.0``
  176. .. rst-class:: classref-property-setget
  177. - void **set_pressure_coefficient** **(** :ref:`float<class_float>` value **)**
  178. - :ref:`float<class_float>` **get_pressure_coefficient** **(** **)**
  179. .. container:: contribute
  180. There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  181. .. rst-class:: classref-item-separator
  182. ----
  183. .. _class_SoftBody_property_ray_pickable:
  184. .. rst-class:: classref-property
  185. :ref:`bool<class_bool>` **ray_pickable** = ``true``
  186. .. rst-class:: classref-property-setget
  187. - void **set_ray_pickable** **(** :ref:`bool<class_bool>` value **)**
  188. - :ref:`bool<class_bool>` **is_ray_pickable** **(** **)**
  189. If ``true``, the **SoftBody** will respond to :ref:`RayCast<class_RayCast>`\ s.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_SoftBody_property_simulation_precision:
  193. .. rst-class:: classref-property
  194. :ref:`int<class_int>` **simulation_precision** = ``5``
  195. .. rst-class:: classref-property-setget
  196. - void **set_simulation_precision** **(** :ref:`int<class_int>` value **)**
  197. - :ref:`int<class_int>` **get_simulation_precision** **(** **)**
  198. Increasing this value will improve the resulting simulation, but can affect performance. Use with care.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_SoftBody_property_total_mass:
  202. .. rst-class:: classref-property
  203. :ref:`float<class_float>` **total_mass** = ``1.0``
  204. .. rst-class:: classref-property-setget
  205. - void **set_total_mass** **(** :ref:`float<class_float>` value **)**
  206. - :ref:`float<class_float>` **get_total_mass** **(** **)**
  207. The SoftBody's mass.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_SoftBody_property_volume_stiffness:
  211. .. rst-class:: classref-property
  212. :ref:`float<class_float>` **volume_stiffness** = ``0.5``
  213. .. rst-class:: classref-property-setget
  214. - void **set_volume_stiffness** **(** :ref:`float<class_float>` value **)**
  215. - :ref:`float<class_float>` **get_volume_stiffness** **(** **)**
  216. .. container:: contribute
  217. There is currently no description for this property. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  218. .. rst-class:: classref-section-separator
  219. ----
  220. .. rst-class:: classref-descriptions-group
  221. Method Descriptions
  222. -------------------
  223. .. _class_SoftBody_method_add_collision_exception_with:
  224. .. rst-class:: classref-method
  225. void **add_collision_exception_with** **(** :ref:`Node<class_Node>` body **)**
  226. Adds a body to the list of bodies that this body can't collide with.
  227. .. rst-class:: classref-item-separator
  228. ----
  229. .. _class_SoftBody_method_get_collision_exceptions:
  230. .. rst-class:: classref-method
  231. :ref:`Array<class_Array>` **get_collision_exceptions** **(** **)**
  232. Returns an array of nodes that were added as collision exceptions for this body.
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_SoftBody_method_get_collision_layer_bit:
  236. .. rst-class:: classref-method
  237. :ref:`bool<class_bool>` **get_collision_layer_bit** **(** :ref:`int<class_int>` bit **)** |const|
  238. Returns an individual bit on the collision mask.
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_SoftBody_method_get_collision_mask_bit:
  242. .. rst-class:: classref-method
  243. :ref:`bool<class_bool>` **get_collision_mask_bit** **(** :ref:`int<class_int>` bit **)** |const|
  244. Returns an individual bit on the collision mask.
  245. .. rst-class:: classref-item-separator
  246. ----
  247. .. _class_SoftBody_method_get_point_transform:
  248. .. rst-class:: classref-method
  249. :ref:`Vector3<class_Vector3>` **get_point_transform** **(** :ref:`int<class_int>` point_index **)**
  250. Returns local translation of a vertex in the surface array.
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_SoftBody_method_is_point_pinned:
  254. .. rst-class:: classref-method
  255. :ref:`bool<class_bool>` **is_point_pinned** **(** :ref:`int<class_int>` point_index **)** |const|
  256. Returns ``true`` if vertex is set to pinned.
  257. .. rst-class:: classref-item-separator
  258. ----
  259. .. _class_SoftBody_method_remove_collision_exception_with:
  260. .. rst-class:: classref-method
  261. void **remove_collision_exception_with** **(** :ref:`Node<class_Node>` body **)**
  262. Removes a body from the list of bodies that this body can't collide with.
  263. .. rst-class:: classref-item-separator
  264. ----
  265. .. _class_SoftBody_method_set_collision_layer_bit:
  266. .. rst-class:: classref-method
  267. void **set_collision_layer_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  268. Sets individual bits on the layer mask. Use this if you only need to change one layer's value.
  269. .. rst-class:: classref-item-separator
  270. ----
  271. .. _class_SoftBody_method_set_collision_mask_bit:
  272. .. rst-class:: classref-method
  273. void **set_collision_mask_bit** **(** :ref:`int<class_int>` bit, :ref:`bool<class_bool>` value **)**
  274. Sets individual bits on the collision mask. Use this if you only need to change one layer's value.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_SoftBody_method_set_point_pinned:
  278. .. rst-class:: classref-method
  279. void **set_point_pinned** **(** :ref:`int<class_int>` point_index, :ref:`bool<class_bool>` pinned, :ref:`NodePath<class_NodePath>` attachment_path=NodePath("") **)**
  280. Sets the pinned state of a surface vertex. When set to ``true``, the optional ``attachment_path`` can define a :ref:`Spatial<class_Spatial>` the pinned vertex will be attached to.
  281. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  282. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  283. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  284. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`