class_skeletonik3d.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/SkeletonIK3D.xml.
  6. .. _class_SkeletonIK3D:
  7. SkeletonIK3D
  8. ============
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A node used to rotate all bones of a :ref:`Skeleton3D<class_Skeleton3D>` bone chain a way that places the end bone at a desired 3D position.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. SkeletonIK3D is used to rotate all bones of a :ref:`Skeleton3D<class_Skeleton3D>` bone chain a way that places the end bone at a desired 3D position. A typical scenario for IK in games is to place a character's feet on the ground or a character's hands on a currently held object. SkeletonIK uses FabrikInverseKinematic internally to solve the bone chain and applies the results to the :ref:`Skeleton3D<class_Skeleton3D>` ``bones_global_pose_override`` property for all affected bones in the chain. If fully applied, this overwrites any bone transform from :ref:`Animation<class_Animation>`\ s or bone custom poses set by users. The applied amount can be controlled with the :ref:`interpolation<class_SkeletonIK3D_property_interpolation>` property.
  15. ::
  16. # Apply IK effect automatically on every new frame (not the current)
  17. skeleton_ik_node.start()
  18. # Apply IK effect only on the current frame
  19. skeleton_ik_node.start(true)
  20. # Stop IK effect and reset bones_global_pose_override on Skeleton
  21. skeleton_ik_node.stop()
  22. # Apply full IK effect
  23. skeleton_ik_node.set_interpolation(1.0)
  24. # Apply half IK effect
  25. skeleton_ik_node.set_interpolation(0.5)
  26. # Apply zero IK effect (a value at or below 0.01 also removes bones_global_pose_override on Skeleton)
  27. skeleton_ik_node.set_interpolation(0.0)
  28. .. rst-class:: classref-introduction-group
  29. Tutorials
  30. ---------
  31. - `3D Inverse Kinematics Demo <https://godotengine.org/asset-library/asset/523>`__
  32. .. rst-class:: classref-reftable-group
  33. Properties
  34. ----------
  35. .. table::
  36. :widths: auto
  37. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  38. | :ref:`float<class_float>` | :ref:`interpolation<class_SkeletonIK3D_property_interpolation>` | ``1.0`` |
  39. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  40. | :ref:`Vector3<class_Vector3>` | :ref:`magnet<class_SkeletonIK3D_property_magnet>` | ``Vector3(0, 0, 0)`` |
  41. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`max_iterations<class_SkeletonIK3D_property_max_iterations>` | ``10`` |
  43. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`min_distance<class_SkeletonIK3D_property_min_distance>` | ``0.01`` |
  45. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`override_tip_basis<class_SkeletonIK3D_property_override_tip_basis>` | ``true`` |
  47. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  48. | :ref:`StringName<class_StringName>` | :ref:`root_bone<class_SkeletonIK3D_property_root_bone>` | ``&""`` |
  49. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  50. | :ref:`Transform3D<class_Transform3D>` | :ref:`target<class_SkeletonIK3D_property_target>` | ``Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)`` |
  51. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  52. | :ref:`NodePath<class_NodePath>` | :ref:`target_node<class_SkeletonIK3D_property_target_node>` | ``NodePath("")`` |
  53. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  54. | :ref:`StringName<class_StringName>` | :ref:`tip_bone<class_SkeletonIK3D_property_tip_bone>` | ``&""`` |
  55. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`use_magnet<class_SkeletonIK3D_property_use_magnet>` | ``false`` |
  57. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  58. .. rst-class:: classref-reftable-group
  59. Methods
  60. -------
  61. .. table::
  62. :widths: auto
  63. +-------------------------------------+--------------------------------------------------------------------------------------------------+
  64. | :ref:`Skeleton3D<class_Skeleton3D>` | :ref:`get_parent_skeleton<class_SkeletonIK3D_method_get_parent_skeleton>` **(** **)** |const| |
  65. +-------------------------------------+--------------------------------------------------------------------------------------------------+
  66. | :ref:`bool<class_bool>` | :ref:`is_running<class_SkeletonIK3D_method_is_running>` **(** **)** |
  67. +-------------------------------------+--------------------------------------------------------------------------------------------------+
  68. | void | :ref:`start<class_SkeletonIK3D_method_start>` **(** :ref:`bool<class_bool>` one_time=false **)** |
  69. +-------------------------------------+--------------------------------------------------------------------------------------------------+
  70. | void | :ref:`stop<class_SkeletonIK3D_method_stop>` **(** **)** |
  71. +-------------------------------------+--------------------------------------------------------------------------------------------------+
  72. .. rst-class:: classref-section-separator
  73. ----
  74. .. rst-class:: classref-descriptions-group
  75. Property Descriptions
  76. ---------------------
  77. .. _class_SkeletonIK3D_property_interpolation:
  78. .. rst-class:: classref-property
  79. :ref:`float<class_float>` **interpolation** = ``1.0``
  80. .. rst-class:: classref-property-setget
  81. - void **set_interpolation** **(** :ref:`float<class_float>` value **)**
  82. - :ref:`float<class_float>` **get_interpolation** **(** **)**
  83. Interpolation value for how much the IK results are applied to the current skeleton bone chain. A value of ``1.0`` will overwrite all skeleton bone transforms completely while a value of ``0.0`` will visually disable the SkeletonIK. A value at or below ``0.01`` also calls :ref:`Skeleton3D.clear_bones_global_pose_override<class_Skeleton3D_method_clear_bones_global_pose_override>`.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_SkeletonIK3D_property_magnet:
  87. .. rst-class:: classref-property
  88. :ref:`Vector3<class_Vector3>` **magnet** = ``Vector3(0, 0, 0)``
  89. .. rst-class:: classref-property-setget
  90. - void **set_magnet_position** **(** :ref:`Vector3<class_Vector3>` value **)**
  91. - :ref:`Vector3<class_Vector3>` **get_magnet_position** **(** **)**
  92. Secondary target position (first is :ref:`target<class_SkeletonIK3D_property_target>` property or :ref:`target_node<class_SkeletonIK3D_property_target_node>`) for the IK chain. Use magnet position (pole target) to control the bending of the IK chain. Only works if the bone chain has more than 2 bones. The middle chain bone position will be linearly interpolated with the magnet position.
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_SkeletonIK3D_property_max_iterations:
  96. .. rst-class:: classref-property
  97. :ref:`int<class_int>` **max_iterations** = ``10``
  98. .. rst-class:: classref-property-setget
  99. - void **set_max_iterations** **(** :ref:`int<class_int>` value **)**
  100. - :ref:`int<class_int>` **get_max_iterations** **(** **)**
  101. Number of iteration loops used by the IK solver to produce more accurate (and elegant) bone chain results.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_SkeletonIK3D_property_min_distance:
  105. .. rst-class:: classref-property
  106. :ref:`float<class_float>` **min_distance** = ``0.01``
  107. .. rst-class:: classref-property-setget
  108. - void **set_min_distance** **(** :ref:`float<class_float>` value **)**
  109. - :ref:`float<class_float>` **get_min_distance** **(** **)**
  110. The minimum distance between bone and goal target. If the distance is below this value, the IK solver stops further iterations.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_SkeletonIK3D_property_override_tip_basis:
  114. .. rst-class:: classref-property
  115. :ref:`bool<class_bool>` **override_tip_basis** = ``true``
  116. .. rst-class:: classref-property-setget
  117. - void **set_override_tip_basis** **(** :ref:`bool<class_bool>` value **)**
  118. - :ref:`bool<class_bool>` **is_override_tip_basis** **(** **)**
  119. If ``true`` overwrites the rotation of the tip bone with the rotation of the :ref:`target<class_SkeletonIK3D_property_target>` (or :ref:`target_node<class_SkeletonIK3D_property_target_node>` if defined).
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_SkeletonIK3D_property_root_bone:
  123. .. rst-class:: classref-property
  124. :ref:`StringName<class_StringName>` **root_bone** = ``&""``
  125. .. rst-class:: classref-property-setget
  126. - void **set_root_bone** **(** :ref:`StringName<class_StringName>` value **)**
  127. - :ref:`StringName<class_StringName>` **get_root_bone** **(** **)**
  128. The name of the current root bone, the first bone in the IK chain.
  129. .. rst-class:: classref-item-separator
  130. ----
  131. .. _class_SkeletonIK3D_property_target:
  132. .. rst-class:: classref-property
  133. :ref:`Transform3D<class_Transform3D>` **target** = ``Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)``
  134. .. rst-class:: classref-property-setget
  135. - void **set_target_transform** **(** :ref:`Transform3D<class_Transform3D>` value **)**
  136. - :ref:`Transform3D<class_Transform3D>` **get_target_transform** **(** **)**
  137. First target of the IK chain where the tip bone is placed and, if :ref:`override_tip_basis<class_SkeletonIK3D_property_override_tip_basis>` is ``true``, how the tip bone is rotated. If a :ref:`target_node<class_SkeletonIK3D_property_target_node>` path is available the nodes transform is used instead and this property is ignored.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_SkeletonIK3D_property_target_node:
  141. .. rst-class:: classref-property
  142. :ref:`NodePath<class_NodePath>` **target_node** = ``NodePath("")``
  143. .. rst-class:: classref-property-setget
  144. - void **set_target_node** **(** :ref:`NodePath<class_NodePath>` value **)**
  145. - :ref:`NodePath<class_NodePath>` **get_target_node** **(** **)**
  146. Target node :ref:`NodePath<class_NodePath>` for the IK chain. If available, the node's current :ref:`Transform3D<class_Transform3D>` is used instead of the :ref:`target<class_SkeletonIK3D_property_target>` property.
  147. .. rst-class:: classref-item-separator
  148. ----
  149. .. _class_SkeletonIK3D_property_tip_bone:
  150. .. rst-class:: classref-property
  151. :ref:`StringName<class_StringName>` **tip_bone** = ``&""``
  152. .. rst-class:: classref-property-setget
  153. - void **set_tip_bone** **(** :ref:`StringName<class_StringName>` value **)**
  154. - :ref:`StringName<class_StringName>` **get_tip_bone** **(** **)**
  155. The name of the current tip bone, the last bone in the IK chain placed at the :ref:`target<class_SkeletonIK3D_property_target>` transform (or :ref:`target_node<class_SkeletonIK3D_property_target_node>` if defined).
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_SkeletonIK3D_property_use_magnet:
  159. .. rst-class:: classref-property
  160. :ref:`bool<class_bool>` **use_magnet** = ``false``
  161. .. rst-class:: classref-property-setget
  162. - void **set_use_magnet** **(** :ref:`bool<class_bool>` value **)**
  163. - :ref:`bool<class_bool>` **is_using_magnet** **(** **)**
  164. If ``true``, instructs the IK solver to consider the secondary magnet target (pole target) when calculating the bone chain. Use the magnet position (pole target) to control the bending of the IK chain.
  165. .. rst-class:: classref-section-separator
  166. ----
  167. .. rst-class:: classref-descriptions-group
  168. Method Descriptions
  169. -------------------
  170. .. _class_SkeletonIK3D_method_get_parent_skeleton:
  171. .. rst-class:: classref-method
  172. :ref:`Skeleton3D<class_Skeleton3D>` **get_parent_skeleton** **(** **)** |const|
  173. Returns the parent :ref:`Skeleton3D<class_Skeleton3D>` Node that was present when SkeletonIK entered the :ref:`SceneTree<class_SceneTree>`. Returns null if the parent node was not a :ref:`Skeleton3D<class_Skeleton3D>` Node when SkeletonIK3D entered the :ref:`SceneTree<class_SceneTree>`.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_SkeletonIK3D_method_is_running:
  177. .. rst-class:: classref-method
  178. :ref:`bool<class_bool>` **is_running** **(** **)**
  179. Returns ``true`` if SkeletonIK is applying IK effects on continues frames to the :ref:`Skeleton3D<class_Skeleton3D>` bones. Returns ``false`` if SkeletonIK is stopped or :ref:`start<class_SkeletonIK3D_method_start>` was used with the ``one_time`` parameter set to ``true``.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_SkeletonIK3D_method_start:
  183. .. rst-class:: classref-method
  184. void **start** **(** :ref:`bool<class_bool>` one_time=false **)**
  185. Starts applying IK effects on each frame to the :ref:`Skeleton3D<class_Skeleton3D>` bones but will only take effect starting on the next frame. If ``one_time`` is ``true``, this will take effect immediately but also reset on the next frame.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_SkeletonIK3D_method_stop:
  189. .. rst-class:: classref-method
  190. void **stop** **(** **)**
  191. Stops applying IK effects on each frame to the :ref:`Skeleton3D<class_Skeleton3D>` bones and also calls :ref:`Skeleton3D.clear_bones_global_pose_override<class_Skeleton3D_method_clear_bones_global_pose_override>` to remove existing overrides on all bones.
  192. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  193. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  194. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  195. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  196. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  197. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`