I am trying to make an animated lock tumbler and the key pins should move along the contour of the key. My goal is to move the pins up when the key passes underneath them by using some sort of snap to surface setting and constraining the motion of the pin to only the Z-axis. I'd also like to set a minimum for the Z-axis so once they get to a certain minimum height they won't drop any lower (to simulate the pins resting at the bottom of the cylinder. I have been doing a lot of searching for snap to surface and motion along a path but I'm not sure that I can use that during an animation. Does anyone have advice on how to approach this? I'm attaching an image of the key with the pins snapped to the part of the key I'd like it to track.
Here's one way, it's not perfect, because of the limitations of the Clamp To constraint.
- Duplicate a central loop of your key, and Header > Object Menu > convert it to a curve. Extend the curve to tip-base level on both sides.
- Place the origins of your tumbler-pins at their tips.
- Assign them each a Clamp To constraint, targeted on the curve.
(It's sensible to get this constraint working on one tumbler to begin with, after settling the curve, making sure its scale is applied, etc.)
Because of the way the constraint interpolates the curve, there's some drift in the horizontal direction. You can eliminate this with another constraint on the tumbler: Limit Location to fix it in all axes apart from up-and-down.
If the whole lot is to be parented to other parts for rigging, it might be better to do that first.
the curve remains editable to make small adjustments to the pin positions, if necessary. Excuse the grotty .gif