Make an arm or leg reach a target, bending the right way and stretching when too far
Hands that grab a ledge or feet that rest on stairs need the joint in between to land in a believable place. The usual attempt gives NaN values for unreachable targets, bends the wrong way, or makes the elbow pop from one side to the other. Here is the solution for two-part limbs.
Why this works
A limb with two parts of fixed length and a fixed shoulder can only reach a target in one or two ways, and the corner between them follows from the three distances alone. Remembering which side the joint bends to keeps the pose from jumping between those two answers.
When not to use it
Wrong for tails, necks or tentacles with more than two parts, and for limbs that must also bend sideways or twist in three dimensions. Use the chain method for long bodies, or play a hand-made clip when the pose is always the same.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- 26 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Make an arm or leg reach a target, bending the right way and stretching when too far" (read_entry arm-reaches-a-point-with-an-elbow-that-does-not-flip) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP