How to animate a rolling ball moving in straight paths with combined axis?

Hello guys. I have an idea for a project that involves a rolling ball. I got the hang of animating the movement of the ball in a neat manner, the problem is how to roll the ball along its movement so that it rolls the way you see it on the top (In this case, the top side is the screen as will be shown next). Here’s a video demonstration of what I did:


(Ball moving without rolling)

I tried animating via rotation keyframes, but somehow it doesn’t end the way it intended to be such as the ball appears to be sliding or the axis of rotation is wrong after a couple of bumps. I tried to switch from XYZ Euler to another but the same problems occurred.

Every bit of help is appreciated, and thanks.

I’d be looking at blender dynamics for this if you want realistic rotation/friction etc.

I found this, maybe it will help… You can make a curve that hits all those points.

1 Like

The thing is I want a looping animation, so applying blender dynamics, even though it provides realistic rotation, would probably mess the loop. But I would try and see what happens.

Hmmmm, interesting. I will try it and see what happens.

Make a looping rolling ball, with proper rotation, sounds like a nightmare. There are very limited paths it could take. It needs to end not only in the same position in which it began, but in the same rotation.

When I read this earlier, before I knew you wanted it to loop, I thought about it a bit and decided, nope, I don’t think Blender can do a proper rolling ball along an arbitrary path, because you need quaternion rotation, and Blender doesn’t interpolate those right. But I thought, maybe somebody else will have some good idea.

But hearing that it’s supposed to loop as well, then the path isn’t arbitrary at all, because there are very few paths that will ever loop both position and rotation, and they need to be carefully designed. So either getting proper rotation for what you want is totally impossible, or you have a specific, carefully engineered path?

Well since it’s a loop, the path is defined because of putting location keyframes and adjusting them using their frequencies. Therefore, I will rely the next of the project on this path. Only problem is the rolling which has to coincide with the ball movement.

If you use an arbitrary path, and you rotate along that path as would happen in perfect physics world, then the rotation at the end won’t be the same at the beginning as at the end.

Consider an infinitely thin wheel with radius 1. If it takes 30 frames to travel a circular path, its rotation will be the same at the beginning and end frames only for paths with a radius that is an even multiple of the wheel’s radius. If the curve does not, it’s length is not an even multiple of the wheel’s circumference, and the wheel is in a different rotation at the end of its path as at its beginning.

1 Like

Hello,
Here is a Geometry nodes attempt (somehow long explanation coming).
You will need a Ball (or similar) object with a radius of 1 units and a Bezier cyclic path with all the points with handles in Free type.
If you want straight paths select the points in Edit Mode, set Handle types to Vector and after that set them to Free.
Basic node structure:

Sampling the curve based on Factor (values from 0 to 1) we transform the ball object.
A value for the Scale will serve us as object radius (originally 1).
The two Align Rotation to Euler nodes are to align the object along the curve.
The Rotate Euler node is to rotate the object using the spline normal as axis.
We animate the Factor from 0 at frame 0 (we are making a loop) to 1 at the end frame of the loop.
The advantage of using a sphere and radians is that the rotation angle is just the distance travelled divided by the radius, so we multiply the total Lenght of the spline by the animated Factor and dividing by the radius we have it.

BUT

At the end of the animation the rotation of the ball is not the same as in the beginning.
Because the length of the path has to be multiple of the Ball radius.
We need a litte trick:

Make the use of a witness (a text object joined to the geometry) to see the total number of turns of the ball at Factor 1. You get the number of turns dividing the angle (in radians) by 2pi and set the Value to String node to some decimals.
You can tweak the path (modify its lenght) until you get a perfect rounded number OR (I prefer this) modify the Radius Value of the Ball.
Since the value you have to add is really small, here is what i do:

Multiply a Value by 0.001 and Add it to the Radius, and change that Value until you get all zeros to the right.

Play your loop. In my case it works.

Hope it helps.

That’s not working for me.

rolltest.blend (910.6 KB)

I’m not sure what you’re doing with your align rotation, but it’s not rotating along the path. It’s rotating only in world Z. I don’t think it’s solvable in GN (maybe solvable in AN) because its rotation at any point depends on its entire history.

I suppose this is solvable by creating rotation keyframes for every single frame, in the plane of motion, or by scripting same. Not for the looping bit, just for the actual rotation of a ball along a path (which is significantly more complicated than the rotation of a wheel along a path.)

Checked your file.

In Edit mode, change the Handle Type of the points to Free.

In the node Editor, connect the Curve Length node to the Group Input Geometry socket for it to read the spline length.

The ball rotates but in the opposite direction, since we are taking the normal of the spline as rotation axis I think the normal is to the other side.
I fixed it multiplying the rotation angle by -1.

Hope it helps.

Okay, thanks. I think it’s working how you designed it.

But it’s still not how balls roll. If we make a right angle, and write its roll at a few places, we can see that it’s fine before the elbow, but rather than changing the direction of its rotation when the path bends, it just rotates in curve Z axis to follow the path:

Where if that ball was rolling toward its new destination, it would look more like this:

Here we have to deal with a balance between physically accurate and aesthetics (or what we want to achieve). A ball has a tendency to roll in the direction it is moving, if we do not account for backspinning, friction and slipping between collisions it should be enough. If you want variation, try to add new rotation axes and play with the possibilities.

Also note that if you are using more than one ball, it will be better to modify the path to change the spline length and not ball radii, as each ball will have different size as to fit the number of rolls in its own path.

Wow, that’s some solution. Never expected the rolling problem required such work. Thanks for the node work, it fixed my problem phenomenally. However, there is this little problem when the ball hits the corner of the path as @bandages stated in his last post. Fortunately, the solution is more than enough for my project, so thanks again @lqppro :clap:.

You are welcome!