# Animating a rolling square wheel effect

I basically want the effect shown in the linked gif, like a cube that roles on the floor and doesn't clip the surface as it moves forward, like a rotating square wheel

I can do the automatic rotation when moving with drivers, but how would I set up the up and down movement as it rotates forward.

https://gyazo.com/8e754d39d4363bd82b1134872f72bbe1

Ok a long hard battle with my very limited math knowledge I think I came to an approximate solution.

It is not at all mathematically perfect, meaning the cube will be slightly floating at times, and will appear to slide or drift slightly, but it is as far as I could go.

I would ask anyone with a better math knowledge to improve on this solution.

You will need to set up drivers for it's rotation in such way that say rotation along Y axis will equal pi*locationX

For the tricky part, the Z height will be driver by something like:

0.5+(abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2))))

Where roty is the rotation along the Y axis and sl will be the length of the side of the cube.

If you want it to react to rotation in two axis jus add the equation above to itself 0.5+(abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2)))) + (abs(cos(2*roty-pi/2))*(sqrt((sl**2)+(sl**2))))

For my case with a 1 x 1 unit cube you would get 0.5+(abs(cos(2*roty-pi/2))*(sqrt(.25**2)))+(abs(cos(2*rotx-pi/2))*(sqrt(.25**2)))

• Is there a blend file for this? – Jayem14 Aug 16 '18 at 16:40