2
$\begingroup$

I'm trying to animate the lock mechanism. So I need each pin to follow the key relief. For this challenge, I made a curve path and give my pin "clamp to" constrain. It follows the path perfectly when I move the key, but it moves not only on the Z-axis. So I add "limit location" constrain to limit X and Y-axis movement. After that pin stays at Z-axis but does not follow the curve exactly. the same story if I copy X and Y coordinate from a static object by "copy location" constrain. I made simplify scene for a better explanation. See gif for more detail. Thanks for any advice. enter image description here enter image description here enter image description here

Thank you all for your advice, they are extremely helpful. "Shrinkwrap" constrain on project mode from Nathan's suggestion works pretty fine if the key angle is not really extreme.

Chris's solution is kind of working, but the key movement is not linear, so it was tricky to make movement for the rest of the pin, and baking animation as an action doesn't help as well. I get a better understanding of constraints thanks to Markus von Broady, now everything is clear. GIF below shows the difference between "Shrinkwrap" (on the right) and baked animation ((on the left)) enter image description here

$\endgroup$
3
  • $\begingroup$ A constraint simply clamps the location to a valid value, so the cone is still being moved as on the first GIF but then is moved horizontally to where it's constrained. $\endgroup$ Commented Jul 16, 2021 at 0:07
  • $\begingroup$ Use a shrinkwrap constraint on project mode to do what you want instead. If you need to make a mesh out of the "key" silhouette to do that, you can always make it a non-rendering mesh. $\endgroup$
    – Nathan
    Commented Jul 16, 2021 at 7:17
  • $\begingroup$ Maybe your shrinkwrap problem is caused just by the curve going below the original cone position? That is, move the cone lower. $\endgroup$ Commented Jul 18, 2021 at 0:01

2 Answers 2

1
$\begingroup$

Fake it 'til you make it ;)

So here is my solution proposal:

  1. just use the object constraint follow path and let the key follow it (Blender does this work for you) - this you see on the left side

  2. you can hide all objects on the left side, this is just where the data comes from

  3. copy your pin and give it an object constraint copy z location to the animated pin

enter image description here

  1. copy your path and give it an object constraint copy x inverted location

enter image description here

  1. move the path to the right location

  2. enjoy the result and have fun!

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ There is a hacky method here to achieve linear horizontal motion: Have the hidden curve x driven by an expression that uses hidden pin's x divided by curve's width, and current frame, to calculate how much that pin is behind/ahead. Due to circular reference in dependency (the pin's location relies on the curve, the curve's location relies on pin), the curve's location will update 1 frame later, avoiding feedback loop. $\endgroup$ Commented Jul 18, 2021 at 10:36
0
$\begingroup$

Your shrinkwrap constraint fails because the original position of the cone is already too far in regards to the target - just move it in the direction opposite to the projection direction:

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .