SkeletonIK.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="SkeletonIK" inherits="Node" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. SkeletonIK is used to place the end bone of a [Skeleton] bone chain at a certain point in 3D by rotating all bones in the chain accordingly.
  5. </brief_description>
  6. <description>
  7. SkeletonIK is used to place the end bone of a [Skeleton] bone chain at a certain point in 3D by rotating all bones in the chain accordingly. A typical scenario for IK in games is to place a characters feet on the ground or a characters hands on a currently hold object. SkeletonIK uses FabrikInverseKinematic internally to solve the bone chain and applies the results to the [Skeleton] [code]bones_global_pose_override[/code] property for all affected bones in the chain. If fully applied this overwrites any bone transform from [Animation]s or bone custom poses set by users. The applied amount can be controlled with the [code]interpolation[/code] property.
  8. [codeblock]
  9. # Apply IK effect automatically on every new frame (not the current)
  10. skeleton_ik_node.start()
  11. # Apply IK effect only on the current frame
  12. skeleton_ik_node.start(true)
  13. # Stop IK effect and reset bones_global_pose_override on Skeleton
  14. skeleton_ik_node.stop()
  15. # Apply full IK effect
  16. skeleton_ik_node.set_interpolation(1.0)
  17. # Apply half IK effect
  18. skeleton_ik_node.set_interpolation(0.5)
  19. # Apply zero IK effect (a value at or below 0.01 also removes bones_global_pose_override on Skeleton)
  20. skeleton_ik_node.set_interpolation(0.0)
  21. [/codeblock]
  22. </description>
  23. <tutorials>
  24. <link title="3D Inverse Kinematics Demo">https://godotengine.org/asset-library/asset/523</link>
  25. </tutorials>
  26. <methods>
  27. <method name="get_parent_skeleton" qualifiers="const">
  28. <return type="Skeleton" />
  29. <description>
  30. Returns the parent [Skeleton] Node that was present when SkeletonIK entered the [SceneTree]. Returns null if the parent node was not a [Skeleton] Node when SkeletonIK entered the [SceneTree].
  31. </description>
  32. </method>
  33. <method name="is_running">
  34. <return type="bool" />
  35. <description>
  36. Returns [code]true[/code] if SkeletonIK is applying IK effects on continues frames to the [Skeleton] bones. Returns [code]false[/code] if SkeletonIK is stopped or [method start] was used with the [code]one_time[/code] parameter set to [code]true[/code].
  37. </description>
  38. </method>
  39. <method name="start">
  40. <return type="void" />
  41. <argument index="0" name="one_time" type="bool" default="false" />
  42. <description>
  43. Starts applying IK effects on each frame to the [Skeleton] bones but will only take effect starting on the next frame. If [code]one_time[/code] is [code]true[/code], this will take effect immediately but also reset on the next frame.
  44. </description>
  45. </method>
  46. <method name="stop">
  47. <return type="void" />
  48. <description>
  49. Stops applying IK effects on each frame to the [Skeleton] bones and also calls [method Skeleton.clear_bones_global_pose_override] to remove existing overrides on all bones.
  50. </description>
  51. </method>
  52. </methods>
  53. <members>
  54. <member name="interpolation" type="float" setter="set_interpolation" getter="get_interpolation" default="1.0">
  55. Interpolation value for how much the IK results are applied to the current skeleton bone chain. A value of [code]1.0[/code] will overwrite all skeleton bone transforms completely while a value of [code]0.0[/code] will visually disable the SkeletonIK. A value at or below [code]0.01[/code] also calls [method Skeleton.clear_bones_global_pose_override].
  56. </member>
  57. <member name="magnet" type="Vector3" setter="set_magnet_position" getter="get_magnet_position" default="Vector3( 0, 0, 0 )">
  58. Secondary target position (first is [member target] property or [member 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.
  59. </member>
  60. <member name="max_iterations" type="int" setter="set_max_iterations" getter="get_max_iterations" default="10">
  61. Number of iteration loops used by the IK solver to produce more accurate (and elegant) bone chain results.
  62. </member>
  63. <member name="min_distance" type="float" setter="set_min_distance" getter="get_min_distance" default="0.01">
  64. The minimum distance between bone and goal target. If the distance is below this value, the IK solver stops further iterations.
  65. </member>
  66. <member name="override_tip_basis" type="bool" setter="set_override_tip_basis" getter="is_override_tip_basis" default="true">
  67. If [code]true[/code] overwrites the rotation of the tip bone with the rotation of the [member target] (or [member target_node] if defined).
  68. </member>
  69. <member name="root_bone" type="String" setter="set_root_bone" getter="get_root_bone" default="&quot;&quot;">
  70. The name of the current root bone, the first bone in the IK chain.
  71. </member>
  72. <member name="target" type="Transform" setter="set_target_transform" getter="get_target_transform" default="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
  73. First target of the IK chain where the tip bone is placed and, if [member override_tip_basis] is [code]true[/code], how the tip bone is rotated. If a [member target_node] path is available the nodes transform is used instead and this property is ignored.
  74. </member>
  75. <member name="target_node" type="NodePath" setter="set_target_node" getter="get_target_node" default="NodePath(&quot;&quot;)">
  76. Target node [NodePath] for the IK chain. If available, the node's current [Transform] is used instead of the [member target] property.
  77. </member>
  78. <member name="tip_bone" type="String" setter="set_tip_bone" getter="get_tip_bone" default="&quot;&quot;">
  79. The name of the current tip bone, the last bone in the IK chain placed at the [member target] transform (or [member target_node] if defined).
  80. </member>
  81. <member name="use_magnet" type="bool" setter="set_use_magnet" getter="is_using_magnet" default="false">
  82. If [code]true[/code], 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.
  83. </member>
  84. </members>
  85. <constants>
  86. </constants>
  87. </class>