Rigging a Rolling Cube

Hi, I’m creating a rig that would allow me to roll a cube around using an empty.
Doing the rotation was pretty straight forward, even though I’d never messed with drivers before, but now I’m struggling to get the cube to go up and down while he rotates.
I even did the math, I know that when the cube is flat on the floor, his is on [Z = 1.0], when he’s on a 45° angle it should be [Z = 1.414215], then back to [Z = 1.0] on 90° and so on…
However I don’t know how to create a constraint for this.
In my mind the obvious thing to do would be to create a constraint that keeps the lowest point of a object at [Z = 0], but I don’t even know if a constraint for this exists…
Does someone have any idea of how to rig this elevation for each “step” of the cube?
Thank you.

And just in case anyone ends up here looking for how to make this rotation, it’s pretty simple.
A quick search for “Blender wheel driver” on youtube will give you everything you need to know.
But in any case, it’s just a Transformation Constraint on the cube with this settings in it.

1 Like

This should help you:

1 Like

With constraints only:

cubeRoll.blend (123.7 KB)

I make a non-rendering proxy for the cube. I look at how far below the floor plane it is (via shrinkwrap constraint from a bone far below). I raise the rendering cube up that much (via first acquiring the world space Z of that bone, measuring the distance by acquiring that Z with a bone in the floor plane, and then copying local position from that bone.)

Note that there’s a bone (“sw”) at world Z = -10. There’s some error in this process, and the error can be minimized (not eliminated) by lowering that bone even further. There’s nothing wrong with putting it at -1000 or -100000. I just put it close by so you could find it.

Not a fan of the transformation technique you’re using to roll the cube-- it just doesn’t work well, not in some easily testable situations like interpolating from 0,0 to 4,4-- but if you’re happy with it, that’s all that matters, so I’ve used it for that demo file.

Can work with any mesh you want-- can work with a monkey, if that’s what you want.