# delay camera xna

I read this tutorial http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Camera_delay.php but i didnot unsterstand it. Is there another way to delay the camera position movement without this Quaternion and the "up position"? Basically i want the camera move slowly to another location, and i tried this:

        view = Matrix.CreateLookAt(cameraPosition, cameraTarget, Vector3.UnitY);
cameraTarget = position;
cameraPosition = Vector3.Lerp(new Vector3(0,8,15), world.Backward * 15,1f);


i want the camera be 15 units from an object, and move slowly until it will be behind it, but this code dosen't work.

Assuming that world.Backward is a constant this line of code is going to return the same value every time.

cameraPosition = Vector3.Lerp(new Vector3(0,8,15), world.Backward * 15,1f);


You want to lerp between the current location and target location.

cameraPosition = Vector3.Lerp(cameraPosition, goalPosition, 0.1f);


Lerp is the interpolation function below so if value1 and value2 are the same frame after frame then returned value will never change.

cameraPosition = value1 + (value2 - value1) * amount


Also you want a value less than between 0 and 1. Ex you value of 1.0f gives you. a value of .5 will move you half way to value2 in one tick. A value of .1 will move you a tenth of the way to value2. Below is why 1.0f is a bad weight.

cameraPosition = value1 + (value2 - value1) * amount
cameraPosition = value1 + (value2 - value1) * 1
cameraPosition = value1 + value2 - value1
cameraPosition = value2

• I know the lerp function and how it works, but I dont know exactly what to do to move the camera position to behind the object Commented Feb 17, 2012 at 12:03
• cameraPosition = Vector3.Lerp(cameraPosition, desiredPosition, 0.1f); Commented Feb 17, 2012 at 14:28
• I did that, and its not working Commented Feb 17, 2012 at 16:12
• @user1202920 I'm afraid you don't appear to know how Lerp works, the third parameter is how far between the two points you want the result, Vector3.Lerp(new Vector3(0,8,15), world.Backward * 15,1f); is the same as world.Backward * 15 Commented Mar 18, 2012 at 17:01
• @DanielCarlsson please be nice. Commented Dec 31, 2012 at 21:02