#### Archived

This topic is now archived and is closed to further replies.

# Camera Interpolation in race game

This topic is 5231 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites
In fact - camera works fine for following. The only problem is that i can''t make it follow smooth

##### Share on other sites
Put the camera on a spring system and attach it to the car.

##### Share on other sites
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

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 10
• 10
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
631752
• Total Posts
3002091
×