I needed IK. People said IK was hard. I did it anyway.
This project provides four classes:
-
GodotIK
ASkeletonModifier
that does all the magic. -
GodotIKEffector
Parented byGodotIK
in the SceneTree, these nodes position the bones, define the chain length, and rotate the affected bone according to theirtransform_behavior
property. -
GodotIKConstraint
An abstract class that is parented byGodotIKEffector
s. Four examples are provided as GDScript implementations:PoleConstraint
,StraightBoneConstraint
,SmoothBoneConstraint
,MaxRotationConstraint
. -
GodotIKRoot
An alternative root node, under which effectors and constraints can be placed. Links intoGodotIK
through aNodepath
refernce.
This is the best implementation I could come up with. It's stable - at least as stable as it gets with constraints.
For further reference, check out the doc_classes/
directory; it tells it all.
SceneTree example: Skeleton3D -> GodotIK -> [GodotIKEffectors] -> GodotIKConstraint
demo_libik.webm
(Video sometimes doesn't load. Refreshing page often helps.)
We have binaries!
- Grab the binaries https://github.com/monxa/GodotIK/releases
- Unpack and copy /addons into <your-project-path>
- git clone
- git submodule init # for godot-cpp
- git submodule update # for godot-cpp
- scons target=template_release # compile.
- cp -r godot_project/addons/libik <your-project-path>/addons
If you recently unsuccessfully cloned or tried to build the repository, it was probably because the godot-cpp submodule was configured to use the SSH origin, which you needed to set up. We have now switched to the HTTPS origin. To fix this, run git submodule sync followed by git submodule update.
This solution uses FABRIK, a positional solver. Because it solves positions first, twist is dynamically calculated in a post-processing step. Positions translate into rotations, then into local transforms.
Pros:
- Extremely flexible and stable.
- Fully customizable constraint interface: Overwrite solver behavior, limit rotations, smooth motion, introduce bone stretch, etc.
Cons:
- Constraints can’t apply twist, as it's inferred dynamically.
- A pole bone-based alternative for twist is under consideration.
I’ve tried to make this as easy to use as possible and am actively improving it. Contributions are welcome!