Sub topic 17
Troubleshooting Flipping, Twisting, and Jitter
This chapter assumes you can build an IK chain with a target and a pole target. It also assumes you know how per-bone IK limits and locks work, and how to switch between Pose Mode and Edit Mode. The scripts use the ArmRig from earlier chapters: upper_arm, forearm, hand_ik, and elbow_pole.
Most IK problems fall into three groups. The chain flips to the wrong side, a bone twists around its own axis, or the pose shakes and jumps. Each group has a small set of causes, and you can check them in a fixed order.
A Diagnostic Order
Work from the cheapest check to the most invasive one. Change one thing at a time, so you know which change fixed the problem.
- Check the chain length on the IK constraint. A chain length of 0 runs up through every parent, which often drags in bones you did not mean to solve.
- Check the rest pose. IK needs a small bend in the rest pose to know which way a joint should fold.
- Check the pole target and pole angle.
- Check the per-bone IK limits and locks.
- Check other constraints on the same bones, and their order in the stack.
- Check the scale of the armature and of the bones.
Flipping
Flipping is when the elbow or knee suddenly swings to the opposite side as the target moves. It usually has one of three causes.
Wrong pole angle
The pole angle rotates the whole chain around the line from the chain root to the target. When you add a pole target, the chain often turns sideways because the bone's roll does not match the pole's direction. The usual fix is to try a pole angle of -90, 90, or 180 degrees until the elbow points at the pole.
import math
import bpy
rig = bpy.data.objects["ArmRig"]
ik = rig.pose.bones["forearm"].constraints["IK"]
# Try the common offsets and read the result in the viewport.
for degrees in (0.0, 90.0, -90.0, 180.0):
ik.pole_angle = math.radians(degrees)
bpy.context.view_layer.update()
print(degrees, rig.pose.bones["forearm"].head)Print the forearm head position for each angle. The correct angle puts the elbow nearest the pole bone. Once you know the value, set it once and leave it.
A straight rest pose
If the chain is perfectly straight in the rest pose, the solver has no bend direction. A tiny bend in the rest pose removes this ambiguity. The arm in this series bends upper_arm slightly toward +Y for this reason. Fix it in Edit Mode by moving the elbow joint a small distance off the straight line. Then clear the pose transforms.
The pole sits on the target line
The pole target works by defining a plane. If the pole lies on the line between the chain root and the target, that plane collapses, and the elbow can flip as the target crosses the line. Keep the pole well off to the side of the arm. For a knee, place it in front of the leg. For an elbow, place it behind the arm.
Twisting
Twisting is rotation around the bone's own length axis, the local Y axis in Blender. It shows up as a candy-wrapper effect in a mesh, or as a forearm that spins when the hand control moves.
Unwanted axes of rotation
An IK solver will use any axis it is allowed to use. An elbow should behave as a hinge, so lock the two axes it should not use. The limits and locks from the earlier chapter do this.
import math
import bpy
rig = bpy.data.objects["ArmRig"]
forearm = rig.pose.bones["forearm"]
forearm.lock_ik_y = True # no twist along the bone
forearm.lock_ik_z = True # no sideways bend
forearm.use_ik_limit_x = True
forearm.ik_min_x = 0.0
forearm.ik_max_x = math.radians(150.0)Remember that these locks only affect the IK solver. They do not stop you from rotating the bone by hand, and they do not affect other constraints. If twisting still appears, check whether another constraint on the same bone is adding rotation.
Bone roll
The local axes of a bone come from its roll, which you set in Edit Mode. If the hinge axis is not the one you expect, the locks above will lock the wrong axes. Open the bone's axes in the viewport, check which local axis points along the hinge, and adjust the roll in Edit Mode. Do this before you build the constraints, because changing roll afterward changes how existing limits behave.
Twist in the rest of the chain
Sometimes the twist comes from the parent. If the upper arm rotates around its own axis during IK, give it a small Y lock or a limit, and leave it free on X and Z so the shoulder can still aim.
Jitter
Jitter is a pose that shakes while you move the target, or one that snaps between two results from frame to frame. Common causes follow.
Target out of reach
When the target is farther away than the chain's total length, the chain straightens and cannot reach it. A straight chain at full extension is unstable, because tiny movements of the target change the angle of the last joint sharply. The pose pops when the target crosses the reach limit. Keep controls inside the reachable range, or enable IK stretch (described in the IK options chapter) so the chain can lengthen instead of straining.
Low iterations
The solver runs a limited number of iterations. A long chain or a target near the limit of reach may not converge, and the result changes slightly each frame. Raise the iteration count on the IK constraint and test again. A higher count costs more time per evaluation, so raise it in steps.
import bpy
rig = bpy.data.objects["ArmRig"]
ik = rig.pose.bones["forearm"].constraints["IK"]
print("iterations before:", ik.iterations)
ik.iterations = 500
print("iterations after:", ik.iterations)Conflicting constraints
Two constraints that fight for the same bone produce jitter. A common case is an IK constraint and a Copy Rotation constraint on the same bone, each pulling toward a different result. Constraints are evaluated from the top of the stack down. Reorder them, lower the influence of one, or remove the one you do not need.
Dependency cycles
If bone A follows bone B through a constraint, and bone B depends on bone A, Blender cannot find a stable order. The result lags by one frame and appears to shake. Look for a control bone that is a child of the bone it is supposed to drive. Controls should usually be separate from the deforming chain, with no parent link back into it.
Scale
Non-uniform scale on an armature object or on a bone in the chain makes the solver's results inconsistent. Apply the object's scale with Ctrl+A in Object Mode, and reset bone scale in Pose Mode.
Quick Reference
| Symptom | Likely cause | First fix |
|---|---|---|
| Elbow points the wrong way when the pole is added | Pole angle does not match bone roll | Try -90, 90, or 180 degrees |
| Elbow flips as the target moves | Pole is near the root-to-target line | Move the pole to the side |
| Chain has no preferred bend | Straight rest pose | Add a small bend in Edit Mode |
| Forearm spins along its length | Free Y axis in IK | Set `lock_ik_y` |
| Limits behave strangely | Bone roll differs from expectation | Correct the roll in Edit Mode |
| Pose pops at full reach | Target outside chain length | Move the target or enable stretch |
| Result differs frame to frame | Too few iterations, or conflicting constraints | Raise iterations, reorder constraints |
Putting It Together
Suppose the arm flips when the hand control crosses over the shoulder. First check the pole position, because a pole placed close to the shoulder line is the most common cause. Then confirm that the rest pose has a bend. Finally, check the elbow hinge limits so that the solver cannot choose a negative bend. Fixing these three in order resolves most flipping without touching any other setting.
Exercise
The forearm of your IK arm spins around its own length whenever you move the hand control, but the elbow bend looks right. Which setting do you check first, and how would you set it in Python?
Show answer
Check the IK locks on the forearm bone. The spin is rotation around the bone's local Y axis, so lock that axis for the IK solver with rig.pose.bones["forearm"].lock_ik_y = True. If the spin continues, look for another constraint on the same bone that adds rotation, and check the bone roll in Edit Mode.
Exercise
The elbow of your arm snaps to the opposite side whenever the hand control moves directly above the shoulder. The pole angle is correct for other positions. What is the likely cause, and what do you change?
Show answer
The pole bone probably lies close to the line between the shoulder and the target, so the plane that defines the bend direction collapses and the solver picks the other side. Move the pole bone well off to the side of the arm (behind it for an elbow), so the target does not cross the line from the root through the pole.