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.


1 Answer 1


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
  • \$\begingroup\$ 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 \$\endgroup\$ Commented Feb 17, 2012 at 12:03
  • \$\begingroup\$ cameraPosition = Vector3.Lerp(cameraPosition, desiredPosition, 0.1f); \$\endgroup\$ Commented Feb 17, 2012 at 14:28
  • \$\begingroup\$ I did that, and its not working \$\endgroup\$ Commented Feb 17, 2012 at 16:12
  • \$\begingroup\$ @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 \$\endgroup\$ Commented Mar 18, 2012 at 17:01
  • \$\begingroup\$ @DanielCarlsson please be nice. \$\endgroup\$
    – ashes999
    Commented Dec 31, 2012 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .