class_skeletonik3d.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/SkeletonIK3D.xml.
  6. .. _class_SkeletonIK3D:
  7. SkeletonIK3D
  8. ============
  9. **Deprecated:** This class may be changed or removed in future versions.
  10. **Inherits:** :ref:`SkeletonModifier3D<class_SkeletonModifier3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  11. 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.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. 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:`SkeletonModifier3D.influence<class_SkeletonModifier3D_property_influence>` property.
  16. ::
  17. # Apply IK effect automatically on every new frame (not the current)
  18. skeleton_ik_node.start()
  19. # Apply IK effect only on the current frame
  20. skeleton_ik_node.start(true)
  21. # Stop IK effect and reset bones_global_pose_override on Skeleton
  22. skeleton_ik_node.stop()
  23. # Apply full IK effect
  24. skeleton_ik_node.set_influence(1.0)
  25. # Apply half IK effect
  26. skeleton_ik_node.set_influence(0.5)
  27. # Apply zero IK effect (a value at or below 0.01 also removes bones_global_pose_override on Skeleton)
  28. skeleton_ik_node.set_influence(0.0)
  29. .. rst-class:: classref-reftable-group
  30. Properties
  31. ----------
  32. .. table::
  33. :widths: auto
  34. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`interpolation<class_SkeletonIK3D_property_interpolation>` | |
  36. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  37. | :ref:`Vector3<class_Vector3>` | :ref:`magnet<class_SkeletonIK3D_property_magnet>` | ``Vector3(0, 0, 0)`` |
  38. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`max_iterations<class_SkeletonIK3D_property_max_iterations>` | ``10`` |
  40. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  41. | :ref:`float<class_float>` | :ref:`min_distance<class_SkeletonIK3D_property_min_distance>` | ``0.01`` |
  42. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`override_tip_basis<class_SkeletonIK3D_property_override_tip_basis>` | ``true`` |
  44. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  45. | :ref:`StringName<class_StringName>` | :ref:`root_bone<class_SkeletonIK3D_property_root_bone>` | ``&""`` |
  46. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  47. | :ref:`Transform3D<class_Transform3D>` | :ref:`target<class_SkeletonIK3D_property_target>` | ``Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)`` |
  48. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  49. | :ref:`NodePath<class_NodePath>` | :ref:`target_node<class_SkeletonIK3D_property_target_node>` | ``NodePath("")`` |
  50. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  51. | :ref:`StringName<class_StringName>` | :ref:`tip_bone<class_SkeletonIK3D_property_tip_bone>` | ``&""`` |
  52. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`use_magnet<class_SkeletonIK3D_property_use_magnet>` | ``false`` |
  54. +---------------------------------------+---------------------------------------------------------------------------+-----------------------------------------------------+
  55. .. rst-class:: classref-reftable-group
  56. Methods
  57. -------
  58. .. table::
  59. :widths: auto
  60. +-------------------------------------+-------------------------------------------------------------------------------------------------+
  61. | :ref:`Skeleton3D<class_Skeleton3D>` | :ref:`get_parent_skeleton<class_SkeletonIK3D_method_get_parent_skeleton>`\ (\ ) |const| |
  62. +-------------------------------------+-------------------------------------------------------------------------------------------------+
  63. | :ref:`bool<class_bool>` | :ref:`is_running<class_SkeletonIK3D_method_is_running>`\ (\ ) |
  64. +-------------------------------------+-------------------------------------------------------------------------------------------------+
  65. | |void| | :ref:`start<class_SkeletonIK3D_method_start>`\ (\ one_time\: :ref:`bool<class_bool>` = false\ ) |
  66. +-------------------------------------+-------------------------------------------------------------------------------------------------+
  67. | |void| | :ref:`stop<class_SkeletonIK3D_method_stop>`\ (\ ) |
  68. +-------------------------------------+-------------------------------------------------------------------------------------------------+
  69. .. rst-class:: classref-section-separator
  70. ----
  71. .. rst-class:: classref-descriptions-group
  72. Property Descriptions
  73. ---------------------
  74. .. _class_SkeletonIK3D_property_interpolation:
  75. .. rst-class:: classref-property
  76. :ref:`float<class_float>` **interpolation** :ref:`🔗<class_SkeletonIK3D_property_interpolation>`
  77. .. rst-class:: classref-property-setget
  78. - |void| **set_interpolation**\ (\ value\: :ref:`float<class_float>`\ )
  79. - :ref:`float<class_float>` **get_interpolation**\ (\ )
  80. **Deprecated:** Use :ref:`SkeletonModifier3D.influence<class_SkeletonModifier3D_property_influence>` instead.
  81. 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.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_SkeletonIK3D_property_magnet:
  85. .. rst-class:: classref-property
  86. :ref:`Vector3<class_Vector3>` **magnet** = ``Vector3(0, 0, 0)`` :ref:`🔗<class_SkeletonIK3D_property_magnet>`
  87. .. rst-class:: classref-property-setget
  88. - |void| **set_magnet_position**\ (\ value\: :ref:`Vector3<class_Vector3>`\ )
  89. - :ref:`Vector3<class_Vector3>` **get_magnet_position**\ (\ )
  90. 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.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_SkeletonIK3D_property_max_iterations:
  94. .. rst-class:: classref-property
  95. :ref:`int<class_int>` **max_iterations** = ``10`` :ref:`🔗<class_SkeletonIK3D_property_max_iterations>`
  96. .. rst-class:: classref-property-setget
  97. - |void| **set_max_iterations**\ (\ value\: :ref:`int<class_int>`\ )
  98. - :ref:`int<class_int>` **get_max_iterations**\ (\ )
  99. Number of iteration loops used by the IK solver to produce more accurate (and elegant) bone chain results.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_SkeletonIK3D_property_min_distance:
  103. .. rst-class:: classref-property
  104. :ref:`float<class_float>` **min_distance** = ``0.01`` :ref:`🔗<class_SkeletonIK3D_property_min_distance>`
  105. .. rst-class:: classref-property-setget
  106. - |void| **set_min_distance**\ (\ value\: :ref:`float<class_float>`\ )
  107. - :ref:`float<class_float>` **get_min_distance**\ (\ )
  108. The minimum distance between bone and goal target. If the distance is below this value, the IK solver stops further iterations.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_SkeletonIK3D_property_override_tip_basis:
  112. .. rst-class:: classref-property
  113. :ref:`bool<class_bool>` **override_tip_basis** = ``true`` :ref:`🔗<class_SkeletonIK3D_property_override_tip_basis>`
  114. .. rst-class:: classref-property-setget
  115. - |void| **set_override_tip_basis**\ (\ value\: :ref:`bool<class_bool>`\ )
  116. - :ref:`bool<class_bool>` **is_override_tip_basis**\ (\ )
  117. 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).
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_SkeletonIK3D_property_root_bone:
  121. .. rst-class:: classref-property
  122. :ref:`StringName<class_StringName>` **root_bone** = ``&""`` :ref:`🔗<class_SkeletonIK3D_property_root_bone>`
  123. .. rst-class:: classref-property-setget
  124. - |void| **set_root_bone**\ (\ value\: :ref:`StringName<class_StringName>`\ )
  125. - :ref:`StringName<class_StringName>` **get_root_bone**\ (\ )
  126. The name of the current root bone, the first bone in the IK chain.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_SkeletonIK3D_property_target:
  130. .. rst-class:: classref-property
  131. :ref:`Transform3D<class_Transform3D>` **target** = ``Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)`` :ref:`🔗<class_SkeletonIK3D_property_target>`
  132. .. rst-class:: classref-property-setget
  133. - |void| **set_target_transform**\ (\ value\: :ref:`Transform3D<class_Transform3D>`\ )
  134. - :ref:`Transform3D<class_Transform3D>` **get_target_transform**\ (\ )
  135. 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.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_SkeletonIK3D_property_target_node:
  139. .. rst-class:: classref-property
  140. :ref:`NodePath<class_NodePath>` **target_node** = ``NodePath("")`` :ref:`🔗<class_SkeletonIK3D_property_target_node>`
  141. .. rst-class:: classref-property-setget
  142. - |void| **set_target_node**\ (\ value\: :ref:`NodePath<class_NodePath>`\ )
  143. - :ref:`NodePath<class_NodePath>` **get_target_node**\ (\ )
  144. 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.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_SkeletonIK3D_property_tip_bone:
  148. .. rst-class:: classref-property
  149. :ref:`StringName<class_StringName>` **tip_bone** = ``&""`` :ref:`🔗<class_SkeletonIK3D_property_tip_bone>`
  150. .. rst-class:: classref-property-setget
  151. - |void| **set_tip_bone**\ (\ value\: :ref:`StringName<class_StringName>`\ )
  152. - :ref:`StringName<class_StringName>` **get_tip_bone**\ (\ )
  153. 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).
  154. .. rst-class:: classref-item-separator
  155. ----
  156. .. _class_SkeletonIK3D_property_use_magnet:
  157. .. rst-class:: classref-property
  158. :ref:`bool<class_bool>` **use_magnet** = ``false`` :ref:`🔗<class_SkeletonIK3D_property_use_magnet>`
  159. .. rst-class:: classref-property-setget
  160. - |void| **set_use_magnet**\ (\ value\: :ref:`bool<class_bool>`\ )
  161. - :ref:`bool<class_bool>` **is_using_magnet**\ (\ )
  162. 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.
  163. .. rst-class:: classref-section-separator
  164. ----
  165. .. rst-class:: classref-descriptions-group
  166. Method Descriptions
  167. -------------------
  168. .. _class_SkeletonIK3D_method_get_parent_skeleton:
  169. .. rst-class:: classref-method
  170. :ref:`Skeleton3D<class_Skeleton3D>` **get_parent_skeleton**\ (\ ) |const| :ref:`🔗<class_SkeletonIK3D_method_get_parent_skeleton>`
  171. Returns the parent :ref:`Skeleton3D<class_Skeleton3D>` node that was present when SkeletonIK entered the scene tree. Returns ``null`` if the parent node was not a :ref:`Skeleton3D<class_Skeleton3D>` node when SkeletonIK3D entered the scene tree.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_SkeletonIK3D_method_is_running:
  175. .. rst-class:: classref-method
  176. :ref:`bool<class_bool>` **is_running**\ (\ ) :ref:`🔗<class_SkeletonIK3D_method_is_running>`
  177. 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``.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. _class_SkeletonIK3D_method_start:
  181. .. rst-class:: classref-method
  182. |void| **start**\ (\ one_time\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_SkeletonIK3D_method_start>`
  183. 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.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_SkeletonIK3D_method_stop:
  187. .. rst-class:: classref-method
  188. |void| **stop**\ (\ ) :ref:`🔗<class_SkeletonIK3D_method_stop>`
  189. 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.
  190. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  191. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  192. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  193. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  194. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  195. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  196. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  197. .. |void| replace:: :abbr:`void (No return value.)`