
itsanecdotal
1426
4
2

I'm working on a procedural mini-golf game, and getting the camera feeling right turned out to be a much bigger task than I was expecting. Between the arbritrary courses and 16 person multiplayer meaning up to 16 balls onscreen, it took me a while to figure it out.
In the process, I implemented some neat debug visualization, so here's a post showing it off.
My first instinct was simply to track the ball with the camera, but even with damping it was nauseating when the ball bounced around.
Instead, I track how far along the course the ball has progressed, using a centreline generated from the sections of the course and smoothed.
I then project the ball's position onto the centreline. You can see how even when it bounces a lot, the projected blue dot tracks smoothly down the course.
Much better already!
But we don't only need to see the ball. We also need to see where we're going!
I take the leading player, and project the position further down the course. Only a little at the beginning, and then further near the end when it's more important to see the hole.
Finally, I project all the tracked points onto the screen, and move the camera to encompass as many as possible. If everything we want to see is in view, the camera will also try to centre on the course.
Hopefully it works so well that nobody thinks about the camera at all.