Jump to content
  • Advertisement
Sign in to follow this  
sobeit

camera following a racing car

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all, I am recently trying to create an algorithm for camera following a car. the ideal movement of the camera is that the camera is being put a distance "d" behind the car, and it will start to move along with the car but with a smaller acceleration, so this will increase "d", and then the camera and the car will reach the same maximum speed. Once the car starts to decelerate, so does the camera but with smaller deceleration. when the car and the camera both stops, d should be the same as the initial value.

 

my current way is to multiply the acceleration and deceleration of the car by a constant K, however because the accel and decel of the car are not the same, the "d" will change after the car and the camera stop.

 

any idea on this? thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
A good follow camera isn't fixed in space relative to the object. Instead it has a life of its own, always trying to get to the right spot and constantly making small changes that give a fluid feel.

In a follow camera, you can have the target camera destination be that point behind+above the car. That isn't the camera's actual location, instead it is the location the camera should attempt to reach.

The camera itself should have its own transformation, its own velocity, and its own parameters to handle acceleration rates when the car speeds up or slows. The camera continuously attempts to move toward the target location, and then turns to look at the car. Add in a few constraints to prevent the camera from getting too far ahead or behind the target point, a collision object to help prevent against low ceilings and annoying walls, and potentially a zoom factor based on the actual distance from the car, and you'll have a pretty comprehensive follow camera.

Share this post


Link to post
Share on other sites
thanks, so I'm trying to do the way suggested. but now the problem turns into how do I determine the velocity and the acceleration of the camera. I tried to use lerp but the end position moves with different velocity sometime even different accleration. i tried to calculate it according to the distance between the camera and the point it keeps going back to, neither does it work well. probably I should combine the distance and the movement infomation of the car to calculate the movement of the camera?

Share this post


Link to post
Share on other sites


but now the problem turns into how do I determine the velocity and the acceleration of the camera

If i understand frob correctly, you shouldn't have to determine it, only set it. You could drop points behind the car and create bezier curves through them, you'll have a nice path for your camera to follow, while looking at points closer to your car. 

Share this post


Link to post
Share on other sites

There are many good examples of implementing this kind of follow camera. Once you wrap your mind around the detail that the camera is its own entity rather than being dependent on the character, everything will fall into place.

 

For an example, here is one that implements a smoothed follow camera with about 10 lines of actual code, and another 40 lines of documentation and boiler plate.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!