Original Post
Okay so heres my problem: "The Basic Proportional Controller (PC) The PC is common in many camera systems. If you have worked on a camera system, you have probably used a PC, though it might have been called something else--terminology for this particular construct is not very consistent. The typical implementation is to set the velocity vector, V, equal to a proportion, C, of the difference between the current position, P, and a target position, Pt: V = C(P1 - P)" to implement this I have created a function in my camera:
void Camera::flyTo(D3DXVECTOR3* destination,float speed)
{
if(destination == NULL)
return;
if(speed == 100 || speed < 0)
return;
//Find the difference between the current position and the target pos
// Figure if current item is closest to viewer
if(Position.x > destination->x)
difference.x = (Position.x - destination->x);
else
difference.x = (destination->x - Position.x);
if(Position.y > destination->y)
difference.y = (Position.y - destination->y);
else
difference.y = (destination->y - Position.y);
if(Position.z > destination->z)
difference.z = (Position.z - destination->z);
else
difference.z = (destination->z - Position.z);
velocity.x = speed* (Position.x - difference.x);
velocity.y = speed* (Position.y - difference.y);
velocity.z = speed* (Position.z - difference.z);
setPositionRel(&velocity);
}
but this seems to make the camera fly away from the target not towards it. Is probably something realy simple that I've overlooked but can anyone help? thanks.