Sub topic 5
Bone Constraints: Stack, Targets, and Influence
This chapter assumes you can create an armature, add bones in Edit Mode, switch to Pose Mode, and set basic keyframes. The scripted examples need basic Python familiarity. Everything here also works through the Bone Constraints tab in the Properties editor.
What a Bone Constraint Is
A bone constraint is a rule attached to a pose bone. It changes the bone's final location, rotation, or scale after Blender has read the values you set by hand or by keyframes. The bone's own transform values (the ones in the N panel) are not rewritten. The constraint changes only the result Blender uses to draw the bone and to move its children.
This has a practical consequence. If you copy the rotation of one bone onto another with a constraint, the second bone's rotation fields still show their old numbers. The viewport shows the constrained pose. When you disable the constraint, the bone returns to what the fields say.
Constraints live on pose bones, not on edit bones. In Python they are in rig.pose.bones[name].constraints. Edit bones have no constraints.
The Parts of a Constraint
Most bone constraints share the same structure:
- Owner: the pose bone that carries the constraint. The constraint changes the owner.
- Target: the object, or a bone inside an armature object, that the constraint reads from. Not every constraint needs one. Limit Rotation, for example, has no target.
- Settings: options specific to the constraint type, such as which axes to copy or the minimum and maximum of a limit.
- Influence: a value from 0.0 to 1.0 that sets how strongly the constraint applies.
- Spaces: the coordinate systems used for the owner and the target. The next chapter covers these. For now, leave them at their defaults.
To target a bone, set two properties. target is the armature object, and subtarget is the name of the bone. If you set only target to an armature, the constraint aims at the armature object's origin, not at a bone. This is a common reason for a constraint that appears to do nothing useful.
The Constraint Stack
A bone can carry several constraints. They form a stack, shown top to bottom in the Bone Constraints tab. Blender evaluates the stack from the top down. Each constraint receives the result of the one above it and passes its own result to the one below.
flowchart TDThe block above is only a placeholder to avoid confusion. The real diagram follows.
Order matters because constraints do not merge. A later constraint can overwrite what an earlier one did. If a Copy Rotation constraint sits above a Limit Rotation constraint, the limit clamps the copied rotation. Reverse them and the copy overwrites the limit, so the limit has no visible effect. Chapter 14 covers order in detail. Here, remember that you can reorder constraints by dragging the handle in the constraint header, and that doing so can change the result.
Adding Constraints
In the interface, select a bone in Pose Mode, open the Bone Constraints tab, and choose Add Bone Constraint. In Python, call constraints.new() with the type name.
import bpy
# Assumes the "ArmRig" object from the earlier armature example exists.
rig = bpy.data.objects["ArmRig"]
bpy.context.view_layer.objects.active = rig
bpy.ops.object.mode_set(mode='POSE')
hand_ik = rig.pose.bones["hand_ik"]
forearm = rig.pose.bones["forearm"]
# Copy the hand control bone's rotation onto the forearm for demonstration.
copy = forearm.constraints.new('COPY_ROTATION')
copy.name = "Demo Copy Rotation"
copy.target = rig # the armature object
copy.subtarget = "hand_ik" # the bone inside that armature
print([c.name for c in forearm.constraints])The name you assign appears in the stack and is the key for looking the constraint up later with forearm.constraints["Demo Copy Rotation"]. If you do not set a name, Blender uses a default based on the type, such as Copy Rotation. Adding a second constraint of the same type gives it a numbered name, for example Copy Rotation.001. Setting your own names avoids lookup mistakes.
Targets in Detail
A target is read in its evaluated state. If the target bone is itself constrained, the constraint on the owner sees the target after its own constraints are applied. This lets you chain behavior from one bone to the next.
Two rules prevent common errors:
- A bone cannot depend on itself. A target that is the owner, or one of the owner's descendants, creates a dependency cycle. Blender shows the constraint in red and ignores it.
- A bone's parent chain is evaluated before the bone. Targeting a child of the owner usually creates a cycle, because the child's position depends on the owner.
The red constraint header is the signal for an invalid target. It also appears when a constraint has a required target that is empty. A constraint with no target set does nothing, and the header is red.
Influence
Influence blends between the constrained result and the result without that constraint. At 1.0, the constraint applies fully. At 0.0, it has no effect. At 0.5, the final result sits halfway between the two.
import bpy
rig = bpy.data.objects["ArmRig"]
forearm = rig.pose.bones["forearm"]
copy = forearm.constraints["Demo Copy Rotation"]
copy.influence = 0.5Two details are easy to miss:
- Influence blends the constraint's own contribution, not the whole stack. With several constraints, each has its own influence, and they apply in order.
- Blending rotation by influence interpolates between two orientations. For large rotation differences, the halfway pose can look different from what you expect. Treat partial influence as a smooth transition, not as an exact average of angles.
You can keyframe influence, drive it from a custom property, or set it by hand. Chapter 16 uses a driver on the IK constraint's influence to build an FK/IK switch. Disabling the constraint with the mute property is different from setting influence to 0. Both stop the effect, but mute is a switch on the constraint that you can keyframe as well, while influence is a continuous value.
| Control | Python property | Effect |
|---|---|---|
| Influence slider | `influence` | Continuous blend from 0.0 to 1.0 |
| Eye icon in header | `mute` | Turns the constraint off entirely when `True` |
| Target bone | `subtarget` | Names the bone the constraint reads |
| Target object | `target` | The object that holds that bone |
Visual Feedback
Bones with constraints show a colored indicator in the viewport when bone constraint display is enabled. In the Properties editor, a constraint that is in error has a red header. The common causes are an empty required target, a dependency cycle, or a target bone name that no longer exists after a rename. Renaming a bone in the interface updates the constraint targets that refer to it. Renaming through an edit-bone script before the constraints exist avoids stale names.
Constraints and Keyframes
When you keyframe a constrained bone, Blender records the bone's own transform values, not the constrained result. If you copy a pose from a constrained bone and paste it elsewhere, you get the underlying values. Chapter 18 explains baking, which converts the constrained result into real keyframes.
Exercise
A forearm bone has a Copy Rotation constraint at influence 1.0 above a Limit Rotation constraint. You move the Limit Rotation constraint above the Copy Rotation constraint. Why does the limit stop having any visible effect, and what are two other reasons a Copy Rotation constraint might show a red header?
Show answer
Constraints are evaluated from the top of the stack down, and each passes its result to the next. With Limit Rotation on top, it clamps the bone's original rotation, and then Copy Rotation replaces the rotation with the target's, so the clamp is overwritten. A red header can also mean the target is empty or has no bone set, or that the target creates a dependency cycle, such as targeting a child of the owner bone.
Exercise
You set copy.target = rig on a Copy Rotation constraint but never set copy.subtarget. What does the constraint copy from, and how do you fix it?
Show answer
It copies from the armature object's own transform, not from a bone. Set copy.subtarget to the name of the bone, for example copy.subtarget = "hand_ik".