Camera Interpolation in race game

Started by
3 comments, last by Andriy U 20 years ago
Hi, there, I am making a small demo for my company. Its a race game. I have a problem with game camera. The idea how it works is common: follow the car from behind and use some inertia for slow down and acceleration (turning as well). Spline interpolation is used for camera smoothness... Here i have a problem - it doesn''t make camera move smooth, i always have some sharpness. Any known good solutions for such camera? thx Andriy
Andriy U
Advertisement
I might not be able to help much but I have seen a seemingly simple way to do this with quaternions. For a racing game you would want the camera to follow the vehicles position but not always its jiterry rotations (I assume). Well either way I have seen code for converting spherical coordinates (a direction vector normalized) to a quaternion, and then a way to interpolate spherically between 2 quaternions.

Also if you do the math you might be able to find a way to take 2 rotation matrices and interpolate spherically between them without using quaternions.

Also if all else fails just use euler angles. Find its current yaw and pitch. Find out what it needs to be (current car rotation angles), subtract to get the difference, and decide what your number of angles to move per second. You might want it too move faster the greater the difference (something like the physics spring for equation) f=-kx; So great the difference the more you move. This might work for angle of change = 0.33 (difference) Do this once per second. So AOC=(0.33f)*(difference)*(timeelasped).

Hope it helps a bit.
In fact - camera works fine for following. The only problem is that i can''t make it follow smooth
Andriy U
Put the camera on a spring system and attach it to the car.
Here''s an idea:

Find a point where you want the camera to ultimately be, perhaps a fixed distance above and behind the car (depending on the orientation of the car of course).

Each frame, move the camera a fixed proportion of the distance between its current position and the target position (perhaps time-dependent, depending on how your game timing works, maybe it''s skewed by time quantum length so camera does not speed up & slow down)

That should prevent the camera from bouncing around *too* much. Unfortunately it won''t stop it flying through objects, that is a harder one

Mark

This topic is closed to new replies.

Advertisement