Every creature in Creature Lab, the fish, the snake, the six-legged thing with tentacles, runs on a single rule: stay exactly one link behind the point ahead of you. In code, that rule is four lines:
That is a distance constraint. The point does not chase, steer, or think. It gets snapped to the circle of radius linkSize around its anchor, at the spot closest to where it already was. The motion you see, the smooth trailing, the whip of a tail, is not programmed anywhere. It falls out of the rule.
Joint 1 follows the head. Joint 2 follows joint 1. By the time the loop reaches the tail, a motion at the head has rippled down the whole body, which is exactly how a rope, a snake, or a streamer behaves.
A pure distance chain can fold back through itself, and a tight turn collapses it into a scribble. Real spines do not do that. So each joint also refuses to bend more than a few degrees from the joint ahead of it. Small limit: a stiff fish. Big limit: a floppy noodle. That one number is the Flexibility slider in Creature Lab.
Give every joint a radius and the skeleton becomes a body: the outline walks down the right side of the circles, around the tail, and back up the left. Head wide, middle wider, tail narrow, and suddenly it reads as a fish. Eyes are two dots placed relative to the head joint. Fins are ellipses pinned to a joint's angle. There is no drawing of a fish anywhere in the code. There are only circles on a chain.
A leg has a new problem: the hip is attached to the body and the foot needs to be planted on the ground. Two pinned ends, with the knee free in the middle. The trick is called FABRIK, forward and backward reaching inverse kinematics, and it is humble: run the distance rule from the foot up, which pins the foot but pulls the hip loose, then run it from the hip down, which pins the hip again. Textbook FABRIK repeats that pair of passes until both ends line up. Creature Lab runs just one pair each frame: the leg starts from where it was a moment ago and the foot only creeps, so a single pass keeps up, and the leg settles over a few frames of walking.
Walking is FABRIK plus one decision: the foot stays planted where it is until the body has moved so far that the leg cannot reach, and only then does it step to a new spot. Feet that never slide are what make the lizard in Creature Lab look alive.
This technique is used all over real games and animation tools. Our version is based on the open source project animal-proc-anim by argonautcode, and the constraint explanations by Johnathon Selstad. The same idea, pushed further, gives you ropes, cloth, ragdolls, and soft bodies. It is one of the best power-to-weight ratios in all of game programming.
Creature Lab's engine is the code you saw above, plus paint. Open the Bones view in the app and you are looking at these exact circles and links.