Sub topic 12
Inverse kinematics with targets
This chapter assumes you can create an armature, parent bones, switch between Edit and Pose modes, and pose a rig with forward kinematics (FK). It also assumes you know what a bone constraint is. It covers how Inverse Kinematics (IK) works in Blender, how to set up a target and a chain length, and the errors you are most likely to hit.
FK versus IK
With FK, you rotate each bone in a chain from the top down. To place a hand, you rotate the shoulder, then the elbow, then the wrist. The result is predictable, but placing an end point exactly takes several adjustments.
With IK, you place the end of the chain and the solver works out the rotations of the bones above it. This suits feet that must stay planted on the ground and hands that must grip an object.
| Aspect | FK | IK |
|---|---|---|
| You control | Each bone's rotation | The position of the chain's end |
| Good for | Arcs, swings, tails, spines | Planted feet, hands on objects |
| Typical problem | End point drifts | Joint flips or wrong bend direction |
How the IK constraint works
In Blender, IK is not a separate mode. It is a bone constraint called Inverse Kinematics, added to a pose bone. The bone that holds the constraint is the end of the chain, often called the tip. The solver rotates that bone and its parents so the tip's tail reaches the target.
Three settings matter most:
- Target: an object, or a bone inside an armature, that the tip tries to reach.
- Chain Length: how many bones, counting from the tip upward through its parents, the solver may rotate. A value of 0 means the whole parent chain up to the root, which is rarely what you want.
- Pole Target: an optional second target that controls the bend direction of the chain (covered below).
Setting up IK in the interface
- Select the armature and enter Pose Mode.
- Select the bone that should reach the target, for example a forearm or shin bone.
- Open the Bone Constraints tab in the Properties editor and choose Add Bone Constraint, then Inverse Kinematics.
- Set Target to an empty (or another object).
- Set Chain Length to the number of bones you want solved, for example 2 for an upper and lower limb.
- Move the target in Object Mode or Pose Mode. The chain follows.
A shortcut: in Pose Mode, select a bone and press Shift+I, then choose To New Empty Object or To Active Bone. This adds the constraint and creates the target in one step, but you should still check the chain length it set.
Setting up IK with Python
The script below builds a two-bone chain and a target. It adds the IK constraint to the end bone and moves the target. It is complete and runs from a fresh scene in the Scripting workspace.
import bpy
# Armature with a two-bone chain
arm_data = bpy.data.armatures.new("IKArmature")
arm_obj = bpy.data.objects.new("IKRig", arm_data)
bpy.context.collection.objects.link(arm_obj)
bpy.context.view_layer.objects.active = arm_obj
bpy.ops.object.mode_set(mode='EDIT')
upper = arm_data.edit_bones.new("upper")
upper.head = (0, 0, 0)
upper.tail = (0, 0, 1)
lower = arm_data.edit_bones.new("lower")
lower.head = (0, 0, 1)
lower.tail = (0, 0, 2)
lower.parent = upper
lower.use_connect = True
bpy.ops.object.mode_set(mode='OBJECT')
# Target empty
target = bpy.data.objects.new("IK_Target", None)
target.location = (1, 0, 1.5)
bpy.context.collection.objects.link(target)
# IK constraint on the end bone
pbone = arm_obj.pose.bones["lower"]
ik = pbone.constraints.new('IK')
ik.target = target
ik.chain_count = 2
bpy.context.view_layer.update()
print("Tip tail:", arm_obj.matrix_world @ pbone.tail)The Python property for Chain Length is chain_count. Because the target sits at distance about 1.8 from the root and the chain is 2 long, the solver can reach it, and the printed tail position lands at or near (1, 0, 1.5).
Controlling the bend with a pole target
A two-bone chain has more than one valid solution. The elbow or knee can bend in several directions, and the solver picks one. A pole target removes the guesswork. It is a second object that the chain bends toward.
In the constraint panel, set Pole Target to an empty placed in front of a knee (or behind an elbow). Then adjust Pole Angle until the chain's roll matches the rest pose. When a limb twists strangely as soon as you add a pole, the cause is almost always the Pole Angle, so try values such as 90 or -90 degrees first.
pole = bpy.data.objects.new("IK_Pole", None)
pole.location = (0, -2, 1)
bpy.context.collection.objects.link(pole)
ik.pole_target = pole
ik.pole_angle = 1.5708 # 90 degrees, in radiansRun this after the previous script, in the same session, so ik is still defined.
Useful IK settings
- Use Tail: when on (the default), the tip's tail reaches the target. When off, the tip's head reaches it instead.
- Stretch: lets bones stretch toward a target that is out of reach. It works together with the per-bone IK Stretch value in the Bone properties.
- Weight and Rotation: let the tip also match the target's orientation, which is useful for feet that must lie flat.
- IK Limits and Locks: set per bone under Inverse Kinematics in Bone properties. Lock axes or set rotation limits so a knee can bend only one way.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Whole rig moves with the target | Chain Length is 0 | Set it to the number of bones you need |
| Limb snaps or flips near full extension | Straight chain, no bend hint | Pre-bend the rest pose slightly, add a pole target, or set limits |
| Bend goes the wrong way | No pole target, or wrong Pole Angle | Add a pole target and tune Pole Angle |
| Constraint seems to do nothing | No target set, or influence is 0 | Check Target and Influence |
| Target cannot be reached | Target farther than chain length | Move the target closer or enable Stretch |
Keyframing IK
IK itself is not keyed. You key the target's location (and the pole, if used), and the solver recomputes the chain each frame. The bones underneath show the result, but their own keys are not needed.
target.location = (1, 0, 1.5)
target.keyframe_insert(data_path="location", frame=1)
target.location = (-1, 0, 1.5)
target.keyframe_insert(data_path="location", frame=24)Exercise
A two-bone leg rig has an IK constraint on the shin bone with Chain Length 0. When you move the foot target, the hips and spine move too. What is wrong, and what do you change?
Show answer
Chain Length 0 lets the solver rotate every parent bone up to the root, so it pulls the hips and spine along. Set Chain Length to 2 so only the shin and thigh are solved.
Exercise
Your IK knee bends backward. You add a pole target in front of the knee, and now the whole leg is twisted sideways. Which setting do you adjust next?
Show answer
The Pole Angle on the IK constraint. Try 90 or -90 degrees (in radians in Python, about 1.5708 or -1.5708) until the leg's roll matches the rest pose.