"Compute a follow slot from the leader's heading, not the line between the pair"
▸ SYMPTOM
- You want a companion to walk beside the leader at a fixed side offset, for example one metre to the left.
- The companion drifts in behind the leader instead, and the pair collapses to single file.
- The offset math looks correct, because at any single instant it does point sideways.
▸ CAUSE
The slot direction is derived from the line between the two characters. That definition is circular.
The offset axis comes from follower.Position - leader.Position, then gets rotated to point sideways. But follower.Position is where the follower already sits, which is the previous frame's result.
So each correction is computed from the last correction. The follower steps toward the slot, which moves the line between the pair, which moves the slot again. Frame over frame the offset direction and the actual offset both decay toward zero, and the follower ends up directly behind the leader.
Measured against a straight-line walk, the line-between-the-pair rule produced 89.6 degrees of error. The leader-heading rule produced 0.2 degrees.
▸ FIX
Derive the side-offset axis from the leader's own forward vector.
- Read the leader's heading, meaning the leader's forward vector, not the vector to the follower.
- Rotate that forward vector 90 degrees to get the slot direction.
- Place the slot at the leader's position plus the slot direction times the side offset.
The slot now depends only on the leader's state, so it no longer reads back the follower's position.
▸ WHY IT WORKS
The leader's forward vector does not depend on where the follower is, so the slot it defines is stable frame to frame. The line between the pair does depend on the follower, so a slot built from it feeds its own output back as its next input, which is the feedback loop that collapses the formation. Removing the follower's position from the slot calculation removes the loop, and the measured error drops from 89.6 degrees to 0.2 degrees.
- Published