# Mechanical rig problem I can't figure out

I'm trying to rig this mechanical leg to go from a 45 degree angle downward, to an upward 90 degree angle like this:

I have a piston sort of mechanism beneath the leg that extends and contracts as the leg moves, however after a certain point the piston can no longer extent far enough and it disconnects, and so I'd like to be able to move the base of the piston upwards right before the piston disconnects.

I'm not sure how to rig that upward motion to react to the rotation of the leg, and also unsure of how to make it only happen after the piston is fully extended, I'm very new to rigging and mostly figuring this out as I go, any help would be appreciated, thanks a bunch!

• Welcome, please consider using the drivers and the law of cosines. Which state is the rest pose, -45 or 90 degree? It's easier to explain if you can share the file. Commented Dec 18, 2022 at 6:23

I call this "IK-to-line", where we want to reach a particular position on a line, but don't much care which point on the line we reach.

ik1 and ikStretch form a 2-chain IK with position, rotation, and stretch enabled. ikStretch has stretch 1.0 in its bone IK settings. ikT, the target for this IK, is in the same rest pose axes as ikStretch. Their Y axes are oriented with the line we want to move along.

What we're getting here is the nearest intersection of a circle and a line. A circle, at origin of ik1, with a radius equal to the length of ik1; and a line, defined by the Y axis of ikT; nearest to the pre-IK tail of ikT. We find this intersection at the post-IK tail of ik1.

Shown on right, this will drag our target up just like you want. But shown in middle, it will also drag our target down, which you may not want. We can fix that with another layer of bones:

Starting with my non-deforming IK as a base, I use a stretch to constraint to reach for the bend in the IK, then use a limit scale constraint to only allow that stretching to shorten the limiter, never extend it. Deform2, parented to it, has inherit scale disabled, and locked tracks Deform1, which locked tracks the tail of the limiter.

Deform1 and Deform2, our piston bones, never pull away from each other, as seen at right, but they can still push into each other, as seen in the middle.

There are other ways that we could limit this. This is just one of several methods.