# Trying to get constant speed

• 04-01-2006
gpr1me
Trying to get constant speed
I am having some trouble figuring this out. Basically i have set up a bunch of predetermined positions on the map which i visit in some predinfined order. The camera follows the path specified. It will go to one position which i set by the center of the gluLookAt() function. The center is the direction my camera is moving. My move function is this:

Code:

```void Camera::MoveForward( void ) {         eye.x += (center.x - eye.x) / step;         //eye.y += (center.y - eye.y) / step;         eye.z += (center.z - eye.z) / step;         center.x += (center.x  - eye.x) / step;         //center.y += (center.y - eye.y) / step;         center.z += (center.z - eye.z) / step; }```
I have commented out the y positions because i do not want it to change. A am also increasing the center position so the camera will not slow down when it gets near the position it's going to. Once it gets to that position i update the center to the next position and it continues.

Now my problem is if i have say 3 positions (p1, p2, p3) i want to camera to go to. It will start at p1->p2->p3. And say the distance between p1 and p2 is 10 and the distance between p2 and p3 is 20. This means that the camera will move from p2 to p3 faster than it moved from p1 to p2.

How should i fix this problem? I am thinking i should have the center position always a constant distance away from my eye position and in the direction of the next position on the map to visit. How would i do this?
• 04-01-2006
Perspective
Just keep some sort of constant velocity value and increase your position by that value instead of the differences between the points.
• 04-01-2006
hdragon
You can normalized the velocity, then set the speed and add the velocity to the position. In this case, the speed will be 10.

Velocity.normalize();
Velocity *= speed;
Position += Velocity;