Sub topic 15
Building a Simple Arm Rig with Control Bones
This chapter pulls the earlier pieces into one working arm rig: IK, a pole target, joint limits, and a switch. It assumes you can already do these things:
- Add bones in Edit Mode and switch between Object, Edit and Pose Mode.
- Add a bone constraint.
- Read basic Python, because the setup is scripted.
- Use pole targets, IK locks and constraint order, which earlier chapters covered.
Deform bones and control bones
A rig usually has two kinds of bones. Deform bones move the mesh. Control bones are what the animator grabs. Separating them lets you change how the rig is driven without touching the skinning.
The arm rig in this chapter has four bones:
| Bone | Role | Parent |
|---|---|---|
| `upper_arm` | Deform bone, first link of the IK chain | None |
| `forearm` | Deform bone, last link of the IK chain, carries the IK constraint | `upper_arm`, connected |
| `hand_ik` | Control bone, the IK target | None |
| `elbow_pole` | Control bone, the pole target | None |
The IK target and pole bones have no parent inside the chain. If hand_ik were a child of forearm, the target would move whenever the solver moved the forearm. That creates a dependency cycle, and the arm would jitter or stop following the target.
Step 1: Build the bones
This script creates the chain, the target and the pole. The upper arm tail sits slightly off the straight line, at y = 0.1, so the solver has a bend direction to start from. A perfectly straight chain gives the solver no preferred bend plane.
import bpy
arm_data = bpy.data.armatures.new("ArmRig")
rig = bpy.data.objects.new("ArmRig", arm_data)
bpy.context.collection.objects.link(rig)
bpy.context.view_layer.objects.active = rig
rig.select_set(True)
bpy.ops.object.mode_set(mode='EDIT')
eb = arm_data.edit_bones
upper = eb.new("upper_arm")
upper.head = (0.0, 0.0, 0.0)
upper.tail = (1.0, 0.1, 0.0) # slight bend so the IK solver has a bend direction
fore = eb.new("forearm")
fore.head = (1.0, 0.1, 0.0)
fore.tail = (2.0, 0.0, 0.0)
fore.parent = upper
fore.use_connect = True
hand_ik = eb.new("hand_ik")
hand_ik.head = (2.0, 0.0, 0.0)
hand_ik.tail = (2.0, 0.0, 0.3)
elbow_pole = eb.new("elbow_pole")
elbow_pole.head = (1.0, 2.0, 0.0)
elbow_pole.tail = (1.0, 2.0, 0.3)
bpy.ops.object.mode_set(mode='POSE')The pole sits at y = 2, away from the arm and in the direction you want the elbow to point. Put the pole bone in line with the bend, not in line with the limb.
Step 2: Add the IK constraint
The constraint goes on the last bone of the chain, here forearm. chain_count = 2 makes the solver move the forearm and its parent only. With 0, the solver would walk up through every parent, which is rarely what you want on a character.
import math
import bpy
rig = bpy.data.objects["ArmRig"]
forearm = rig.pose.bones["forearm"]
ik = forearm.constraints.new('IK')
ik.target = rig
ik.subtarget = "hand_ik"
ik.pole_target = rig
ik.pole_subtarget = "elbow_pole"
ik.pole_angle = math.radians(-90.0) # adjust until the elbow bends toward the pole
ik.chain_count = 2 # forearm and upper_arm; 0 would use the whole chainMove hand_ik in Pose Mode. The arm should follow. Then check the elbow. If it bends away from the pole, or the chain sits rotated around its own axis, change pole_angle until the bend faces the pole. The right value depends on bone roll, so the -90 here is a starting point and not a rule. A multiple of 90 degrees is usually correct.
Step 3: Make the elbow a hinge
Without limits, the solver can bend the elbow on any axis, including backward. Per-bone IK locks and limits tell the solver which rotations it may use. This turns the elbow into a hinge that bends only on local X, between 0 and 150 degrees.
import math
import bpy
rig = bpy.data.objects["ArmRig"]
forearm = rig.pose.bones["forearm"]
# Make the elbow a hinge that only bends on its local X axis, between 0 and 150 degrees.
forearm.lock_ik_y = True
forearm.lock_ik_z = True
forearm.use_ik_limit_x = True
forearm.ik_min_x = 0.0
forearm.ik_max_x = math.radians(150.0)These settings only affect the IK solver. If you also pose the bone by hand (FK) or drive it with another constraint, nothing clamps it. For a hard guarantee on the final pose, add a Limit Rotation constraint on the same bone with owner_space = 'LOCAL', as covered in the limit constraints chapter. Use matching ranges in both places so the solver does not fight the clamp.
Step 4: Add an FK/IK switch
A rig is more useful when the animator can choose between IK and FK per shot. IK influence from 0 to 1 blends the solver's result in over the pose you set by hand. A custom property on the control bone holds the switch, and a driver connects it to the constraint.
import bpy
rig = bpy.data.objects["ArmRig"]
forearm = rig.pose.bones["forearm"]
hand_ik = rig.pose.bones["hand_ik"]
hand_ik["ik_switch"] = 1.0 # custom property: 1 = IK on, 0 = IK off
ik = forearm.constraints["IK"]
fcurve = ik.driver_add("influence")
driver = fcurve.driver
driver.type = 'AVERAGE'
var = driver.variables.new()
var.name = "switch"
var.type = 'SINGLE_PROP'
var.targets[0].id = rig
var.targets[0].data_path = 'pose.bones["hand_ik"][\"ik_switch\"]'With AVERAGE and one variable, the influence equals the property value. Set ik_switch to 0 and the arm returns to the FK pose on upper_arm and forearm. Values between 0 and 1 blend the two. The property is visible in the Bone tab under Custom Properties, so animators do not need to open a script.
Constraint order on the control bones
If you add helper constraints later, the order within one bone's stack matters. Constraints run top to bottom, and each one sees the result of the one above. On forearm, keep IK first and any Limit Rotation after it. Putting the limit before IK means the solver overwrites the limit.
Bones evaluate parent before child, and a constraint's target is evaluated before its owner. That is why the target bones sit outside the chain. A tracking constraint, such as a Damped Track that keeps a wrist twist bone aimed at the hand, works the same way. Its target must not depend on its owner.
Testing the rig
Check these in Pose Mode before animating:
- Move
hand_ikthrough the arm's full reach. The arm should stay on the target until it reaches full extension. - Move
hand_ikpast full reach. The chain straightens and the hand lags behind the target. That is expected without stretch. - Move
elbow_polearound the arm. The elbow should follow it. - Drag
hand_ikclose to the shoulder. The elbow should fold only in the allowed direction. - Set
ik_switchto0and rotate the bones by hand. FK should work without the solver interfering.
Exercise
You add a Damped Track constraint to handik so it always points at the elbowpole bone, and the arm starts to jitter. A teammate suggests parenting hand_ik to forearm to "keep them together". Why does that make things worse, and what is a safer arrangement?
Show answer
Parenting handik to forearm makes the IK target depend on the bone the IK constraint moves. The target moves when the solver runs, so the solver chases a moving target, which is a dependency cycle and causes jitter or lag. Keep handik and elbow_pole outside the IK chain with no parent, or parent them to a root or body control that the chain does not feed into. Any helper constraints that read from the chain should go on separate bones, not on the control bones that the IK constraint targets.