Sub topic 13
Damped Track, Track To, and Stretch To
This chapter covers the three tracking constraints in Blender: Damped Track, Track To, and Stretch To. Each one makes a bone point at a target. I assume you can create an armature, switch to Pose Mode, add a bone constraint, and read a short Python script. I also assume you know what owner space and target space mean from the previous chapters.
What a tracking constraint does
A tracking constraint changes the rotation of the owner bone so that one of its axes points at a target. It does not move the bone's head. In a bone, the Y axis runs from head to tail, so most rigs aim the Y axis at the target.
The three constraints differ in how they handle the leftover rotation around the aimed axis. That rotation is called roll or twist. Aiming one axis at a point leaves the bone free to spin around that axis. Each constraint resolves this in its own way.
| Constraint | Aims the bone's axis at the target | Controls roll | Changes bone length |
|---|---|---|---|
| Damped Track | Yes, by the shortest rotation | No, roll is kept from the existing pose | No |
| Track To | Yes | Yes, through an up axis | No |
| Stretch To | Yes, with the Y axis | Partly, through a volume setting and the rest of the stack | Yes |
Damped Track
Damped Track rotates the bone by the smallest rotation that points the chosen axis at the target. Because it takes the shortest path, it adds no roll of its own. Whatever twist the bone had before the constraint, it keeps.
This makes Damped Track the safest choice for an aim that must not spin the bone unexpectedly. Typical uses are an eye that follows a target bone, a finger that points at a control, or a helper bone that points at another joint.
The constraint has one main setting, the track axis. For a bone it is usually Y, which points the bone along its length. You can also pick the negative axes, such as -Y.
Damped Track has one failure case. When the target passes directly behind the owner, the shortest rotation is undefined, because any direction of turn is equally short. The bone can flip suddenly at that point. Keep targets away from the line directly opposite the aim axis.
import bpy
rig = bpy.data.objects["ArmRig"]
bpy.context.view_layer.objects.active = rig
bpy.ops.object.mode_set(mode='POSE')
hand = rig.pose.bones["hand_ik"]
con = hand.constraints.new('DAMPED_TRACK')
con.target = rig
con.subtarget = "elbow_pole"
con.track_axis = 'TRACK_Y'This script assumes the ArmRig object from the earlier chapter, which has a hand_ik bone and an elbow_pole bone. After you run it, the hand_ik bone turns so that its Y axis points at elbow_pole.
Track To
Track To aims one axis at the target and also keeps a second axis pointing up. The two axes are the track axis and the up axis. Together they fully define the bone's orientation, so there is no free roll left.
This is useful when you want a consistent orientation, such as a head that turns toward a point while staying upright. The up axis tells Blender which side of the bone should face the world's up direction.
The settings are:
- Track Axis: the bone axis that aims at the target. For bones this is normally
Y. - Up Axis: the bone axis that should stay upward. It must differ from the track axis, for example
Z. - Target Z: when enabled, the up axis aligns with the world Z axis rather than with the target's Z axis.
Track To has a known problem. If the track axis and the up axis are the same, or if the target lies along the world's up direction, the orientation is ambiguous and the bone can flip or spin. Blender does not warn you when the two axes match, so a setup that looks right at first can break once the target moves.
import bpy
rig = bpy.data.objects["ArmRig"]
bpy.context.view_layer.objects.active = rig
bpy.ops.object.mode_set(mode='POSE')
hand = rig.pose.bones["hand_ik"]
con = hand.constraints.new('TRACK_TO')
con.target = rig
con.subtarget = "elbow_pole"
con.track_axis = 'TRACK_Y'
con.up_axis = 'UP_Z'
con.use_target_z = True> Track To has a different default for objects than for bones. When you add it to a bone, check the track axis first. A bone that points the wrong way after you add the constraint usually has the wrong track axis.
Compare the two. Use Damped Track when you want the least interference with the pose. Use Track To when you need a fully determined orientation and can keep the target away from the singular directions.
Stretch To
Stretch To points the Y axis at the target and also scales the bone along Y so that the tail reaches the target. The bone gets longer when the target moves away and shorter when it moves closer.
It is the usual tool for squash and stretch, for tendons and muscle helpers, and for a bone that must always span the distance between two points. Mechanical examples are a piston or a rubber band.
Stretch To has these settings:
- Rest Length: the length at which the bone has a scale of 1. Setting it to
0makes Blender use the bone's current length. - Volume Variation: how much the bone thickens when it shortens and thins when it lengthens.
- Volume Axes: which axes the volume change applies to. The options are
X,Z, or both. - Plane: the orientation of the bone's remaining axes. It matters only when you combine Stretch To with other constraints.
The Volume Variation setting keeps the bone's apparent volume constant. At a value of 1.0, a bone stretched to twice its length is thinner by a matching factor in the volume axes. A value of 0 leaves the width unchanged.
import bpy
rig = bpy.data.objects["ArmRig"]
bpy.context.view_layer.objects.active = rig
bpy.ops.object.mode_set(mode='POSE')
forearm = rig.pose.bones["forearm"]
con = forearm.constraints.new('STRETCH_TO')
con.target = rig
con.subtarget = "hand_ik"
con.rest_length = 0.0
con.bulge = 1.0
con.volume = 'VOLUME_XZX'In the Python API, the Volume Variation setting is bulge, and the Volume Axes setting is volume. The value VOLUME_XZX applies the change to both X and Z.
Stretch To scales the bone, so any child bones inherit the scale unless their parent settings stop it. If a child bone looks distorted, check its Inherit Scale option in the Bone properties.
Choosing between them
| Situation | Constraint |
|---|---|
| An eye or fingertip that follows a target | Damped Track |
| A head that follows a target and stays upright | Track To |
| A bone whose length must match a distance | Stretch To |
| A helper bone that points at a joint without changing its roll | Damped Track |
The diagram shows how to decide.
Combining tracking constraints with the rest of the stack
Constraints in a bone's stack run from top to bottom, and each one works on the result of the one above. A tracking constraint placed after a Copy Rotation constraint will overwrite the rotation that Copy Rotation produced, unless you lower its influence. The next chapter covers order in detail, but two points matter now.
- Put a tracking constraint above any Limit Rotation constraint on the same bone, so the limit clamps the tracked result.
- A bone that has an IK constraint is solved first. A tracking constraint on the same bone then acts on the IK result, which usually breaks the chain's aim. Put tracking constraints on helper bones, not on bones inside an IK chain.
Common errors
- The bone points the wrong way. The track axis does not match the direction you want. Try
Yor-Yfirst. - The bone flips when the target moves past it. This is the singular case for Damped Track, or the matching-axes case for Track To. Move the target, or switch to a constraint with an explicit up axis.
- The bone does not reach the target. Damped Track and Track To only rotate. Use Stretch To if the length must follow.
- A child bone becomes squashed. The child inherits the stretch. Turn off Inherit Scale on the child.
- Nothing happens. The influence is
0, or the target field is empty. A target armature without a bone name insubtargetpoints at the armature's origin.
Exercise
You want a helper bone to aim at a control bone without adding any twist of its own, and the control bone will never move behind the helper. Which constraint do you choose, and which track axis do you set for a normal bone?
Show answer
Use Damped Track with the track axis set to Y. Damped Track takes the shortest rotation, so it adds no roll. The Y axis is the bone's length direction, so it points the bone at the target.
Exercise
A Track To constraint makes a head bone spin wildly when the target rises directly above it. What causes this, and how can you reduce the problem?
Show answer
The target lies along the up direction, so the track axis and the up reference are nearly parallel and the orientation is ambiguous. Keep the target away from the world's vertical line above the bone, or use Damped Track if you do not need a controlled up axis.