how do racing games typically angle cameras to look as nice as they do when turning? How do they make it look natural and gradual, yet still functional?

967 views

how do racing games typically angle cameras to look as nice as they do when turning? How do they make it look natural and gradual, yet still functional?

In: Mathematics

10 Answers

Anonymous 0 Comments

Having worked on a racing game that was never released, there are a LOT of ways to do this.

Unfortunately there’s no real rigid set of rules for what you do to make the camera good, you just kind of have to experiment with what works.

One example though…

Rail Guide: Along the expected courses of travel there’s an invisible rail that the camera slides along. It is NOT fixed to the rail, but it is guided strongly by it. When the vehicle is directly under the rail, the camera is on the line. When the vehicle is 1 unit to the left, the camera moves 1 unit to the left. When the vehicle is 2 units to the left, the camera is 1.8 units to the left. The camera follows the car, but the further the car gets from the rail, the less the car pulls on the camera, but the camera still points at the car. This behavior means that when the car is banking widely around a turn, you get that somewhat swooping-to-the-side motion of the camera.

But what about when the car completely leaves the area around the rail, wouldn’t that look weird? Oh yes! So that’s why you have an ability for the car to get so far away that the camera snaps off the rail. Except snap is a bad word, that’s jarring and looks terrible. So what you do is set a max distance between the car and rail and you rig up a smoothed approach. Once the distance gets within a few units of your max, you gradually start to lessen how much control the rail has over the position of the camera. This way as the player leaves the rail, the camera doesn’t suddenly snap into motion relative to the car.

But what about the fact that they can leave the rail at different rates (imagine gradually drifting away, vs not turning at a 90 degree bend)? Well, now you have to get into some predictive stuff. Instead of having that distance where you begin your transition away from the rail be fixed, you set an invisible ball slightly out front of the car and you have your “set point” (which was previously fixed) which can adjust closer/farther to the max level based on the calculated acceleration of distance-change between the forward invisible point and the line. In short, if the invisible point suddenly ‘accelerates’ drastically, this is the situation where the car didn’t take the turn. With a high acceleration you’d want the deviation from your set point to be LARGE, so you start transitioning your camera off the rail sooner.

There’s more detail that can be added, but roughly where I’m getting at is that for really nice and smooth camera work, there’s basically no singular tiny piece of code that’s going to do it. Systems on systems, with systems between to smooth the transition.

The most important advice that I can give is to make your set-point variables easy to adjust. If you are working in Unity, have those variables accessible from the Inspector Tab. The reason for this is that no matter what system you develop, there’s going to be variables to adjust it. A wrong variable can make a perfectly fine system appear like garbage, so there’s going to be a lot of trial and error.

The second most important advice is, don’t settle for the local maxima. If you find a set of variables that is “pretty good” but it’s not actually as good as you want it to be no matter how you tweak the variables, don’t just accept that as the best you can do. Slap another system on. Scrap the whole system and start over.

And on a note from Sid Meier, if a variable is worth adjusting, don’t up it by tiny increments. If you think +/-1 might do, then FIRST try +/-5. It’s hard to quantify small changes, its easy to quantify big changes. If +5 doesn’t do what you want, then switch to the -5. If +5 did what you want but it did it too hard, now you can start narrowing down. Try 2.5 as a shift. Etc.

Good luck!

You are viewing 1 out of 10 answers, click here to view all answers.