# LookAt() functionality for FPS (Euler Angle) Camera

This topic is 3213 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a FPS style camera that accumulates Euler angles, and works well. But now I want to implement a lookAt( Vector ) method which will take in a vector, and then calculate an absolute rotation in Euler Angles to aim the camera at that point in space. This is what I have so far:
    void lookAt( float x1, float y1, float z1 )
{
VectorR3 v( x1, y1, z1 );
v.x = m_position.x - v.x;
v.y = m_position.y - v.y;
v.z = m_position.z - v.z;

float r = v.length();
float yaw = acos( v.z / r );
float pitch = atan2( v.y, v.x );

setRotation( yaw, pitch, 0.0f, true ); // This just wraps the values to ensure they stay within range
}


Bbuutt... things aren't working. This is Cartesian Coordinate to Spherical coordinate conversion, or at least it's suppose to be. Does anything jump out as majorly wrong here?

Crossposted.

##### Share on other sites

This topic is 3213 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

This topic is now closed to further replies.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633705
• Total Posts
3013463
×