How can I make a rolling ball follow a path and also apply physics to it? The ball needs to roll at a variable speed and when it hits a wall, it needs to stop or when there’s a hole in the ground it needs to fall in…
Now I’ve followed a tutorial on an object following a spline, so I know the basics of how that works, but I wonder if that’s really the way to go for me. I couldn’t figure out how to apply physics to the object so it stayed on the ground / hit a wall or anything. Then also, how could you adjust the speed of the ball, etc.
I’m kind of lost and need a pointer in the right direction. Thank you in advance.
Don’t think using a spline and physics are going to be very compatible. Moving an object on a spline means telling the object where to be at all times. Physics necessitates the object having freedom of movement to have collisions and rebound from them/slow down or speed up. If you have an object moving along a spline and then a hole in the ground and your spline doesn’t follow the hole down the object will continue to follow the spline across the hole. If the object has physics enabled physics will want to pull the object down and the spline will tell the object not to fall. They won’t play nicely together and the spline will override the physics. What you’re describing is a physics based system. The only thing you might be able to get away with is toggling physics on and off but honestly that seems to be a pain and I don’t know how you would even know when to turn it on or off.
The rolling template could be a reference of physics-based rolling ball. In your case, one way is to add a impulse on your ball. The impulse is direct to a further point of spline. Once it working with gravity, your requirement would be achieved.
So how to control the impulse or more impulse, could be part of your game design.