Advertisement Jump to content
Sign in to follow this  

Camera Interpolation

This topic is 4930 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

I'm working on a intro for my game. It involves me scripting a camera (in OpenGL) somehow that'll follow something and then once that object hits it's destination then the camera will zoom far out revealing this even bigger object. Would anybody have any idea how to run this? I have camerapos and camerarotation vectors. I just need some interpolation functions or something to get me started. Any pitfalls people have come under while doing this? Any information will help! Thanks!

Share this post

Link to post
Share on other sites
If you want the camera position to interpolate from one point to another in a straight line.

Will do an exaple here of moving from 0,0,0 to 10,10,10 - You will need a little bit of vector mathematics here

Vector3 destinationPos(10.0f, 10.0f, 10.0f);
Vector3 sourcePos(0.0f, 0.0f, 0.0f);
float speed = 0.1f;

while (moving)
// speedup/slow down on user input
if (key == speedup)
speed += 0.1f;
else if (key == slowdown)
speed -= 0.1f

Vector3 vecDifference = destinationPos - sourcePos;
// check if we reached the destination
if (vecDifference.Length() < EPSILON)
moving = false;

// update position
sourcePos += vecDifference * speed; // multiply by a scalar not a vector

If you dont want it to follow a straight line, you will need to step along a spline of some kind, just increasing t as you go. You can do exactly the same thing with the cameras look at position.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!