I've been following this tutorial by GiantCowFilms How do I rig a BB-8 robot? and it works fine from a front and back direction starting in the centre of the grid, but when you move diagonally, it starts to rotate almost entirely on the Z axis. I'm not sure what I am doing wrong here. I've posted the .blend.
Here's a screenshot of the him moving properly:
And this is the issue moving diagonally:
EDIT: I found a workaround that utilizes the above method with another. I don't quite understand the math behind it but it works.
1. First, go to blenderartists.org and check out Rigging a Rolling Sphere (BB8) and download the file roller.blend (important: to actually make the sphere move in this file, I had to click "update dependencies" in the driver panel for each axis (W, X, Y, Z)
You should see a screen like this:
And this is where you would update dependencies:
2. There are a number of ways to do this I'm sure, but what I did was to copy the sphere (ctrl + c) to buffer and paste it into my file with BB-8.
3. Then copy the code in text editor and paste into your file or save it as a text document and open it in your new file. Now run the script (also make sure you have "auto-run python scripts" enabled under file in your user preferences) and update your dependencies. It's important to note this script can only work with one sphere at a time...you must manually make the settings of your BB8 body the same as the sphere you pasted in your BB-8 file. This will be outlined in the next step.
4. Now here comes the tedious part. To add the correct drivers to your BB8 body, you need to make sure you are using Quaternion rotation or else this won't work. Go into your rotation options in the Transform panel and change it to Quaternion. Click in each coordinate and type the # sign and enter. They should all be zero and purple.
Then in the drivers section of the graph editor go in to each axis (W, X, Y, Z) and add your scripted expression and variables exactly as shown. Also make sure that the variable type is set to the Transform Channel and that the object is your BB8 body, not the cube as is shown (that is your original sphere you copied from the roller.blend file). It's pretty complicated to explain every single step, but basically you just need to manually duplicate all the settings of the sphere (confusingly labeled cube) in the roller.blend file in your new file to your BB8 body. And don't forget to update dependencies when you are done!
5. If you followed GiantCowFilm's method like I did earlier, just parent the circle empty around the body of BB8 to the body itself. Everything should move properly now!
Again, if you have a hard time with the instructions, you can refer to the original forum posting I found this from Blenderartists Rigging a Rolling Sphere (BB8)
And for those of you who want to torture yourself with the math behind ezaacque's code:
"I am taking each change in position, and calculate the cross product with a vector straight up, to get the vector perpendicular to these two, to get the axis for a wheel, following that change in position. Also, from the distance the wheel rolls, I calculate the angle the wheel needs to turn, in radians. From axis and angle I create a Quaternion rotation, which is then fed into the rotation of the sphere. In fact, I add up all rotations of all changes in position."