Skip to content
/ GodotIK Public

3D Inverse Kinematics (IK) for Godot 4.3+! Supports scriptable constraints and multiple chains.

License

Notifications You must be signed in to change notification settings

monxa/GodotIK

Repository files navigation

GodotIK

3D Inverse Kinematics for Godot 4.3+

I needed IK. People said IK was hard. I did it anyway.

This project provides four classes:

  • GodotIK
    A SkeletonModifier that does all the magic.

  • GodotIKEffector
    Parented by GodotIK in the SceneTree, these nodes position the bones, define the chain length, and rotate the affected bone according to their transform_behavior property.

  • GodotIKConstraint
    An abstract class that is parented by GodotIKEffectors. 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 into GodotIK through a Nodepath 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

demo_libik.webm

(Video sometimes doesn't load. Refreshing page often helps.)

Getting started

We have binaries!

The easy way

  1. Grab the binaries https://github.com/monxa/GodotIK/releases
  2. Unpack and copy /addons into <your-project-path>

The hard way (build it yourself)

  1. git clone
  2. git submodule init # for godot-cpp
  3. git submodule update # for godot-cpp
  4. scons target=template_release # compile.
  5. 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.

Tradeoffs

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!

About

3D Inverse Kinematics (IK) for Godot 4.3+! Supports scriptable constraints and multiple chains.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published