Clamping to a path in only one axis (to make a cam / follower).

Hi, I’m trying to make a cam & follower. One object is restricted to move in the Z axis, another is restricted to move in the X axis and its top surface is uneven. The first object (follower) rests on the second (cam). Exactly like this:

http://www.dtonline.org/apps/infopage/app?1&6&1&28&0&0

Is there any way to do that in blender? I’ve tried using the physics engine, but can’t work it out. Another option I thought was to make a curve that matches the cam profile, and use the Clamp To constraint, but it doesn’t quite work - it moves the follower in the X axis a little bit. Adding a Limit Location constraint just sets X to 0, but then it is at slightly the wrong height.

Any ideas? I’m starting to think this is impossible.

I use a limit distance constant for round cam but it is not perfect. A driver would work. How about this? http://www.pasteall.org/blend/18587

Make an empty… parent the cube that is to move along the cam… to the empty… then use the shrinkwrap modifier on the empty object… place the cam object in the modifier…

like this…

[ATTACH]210176[/ATTACH]