Advertisement Jump to content
Sign in to follow this  

First person Camera movement

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya, I'm trying to create a first person camera for my application, I've already got the camera to move backwards and forwards and rotate, however what I want to do is implement turning into the movement properly. What I need to know is when I rotate the camera on the Y axis (to look left and right), how do I use this angle to calculate how much the camera location should move forwards on the Z axis , and to the side on the X axis when the forward key is pressed. At the moment when the camera turns, it is effictively just "looking" around, not turning.. If you get my drift Thanks

Share this post

Link to post
Share on other sites
If you only want to rotate your camera on Y axis you could try something like that

/* (lx,ly,lz) The focus of the camera */
/* angle_h rotation Y axxis. angle_v rotation from ?? axxis. I don't remenber! */

lx = sin(angle_h)*cos(angle_v);
ly = -sin(angle_v);
lz = -cos(angulo_h)*cos(angle_v);

/* Flat movement */
/* (x,y,z) position of the camera
/* i = 1 forward , i = -1 backward */

x = x + i*(lx)*velocity;
//y = y + i*(ly)*velocity;
z = z + i*(lz)*velocity;

Well something like that.I hope it will give you a clue(but maybe it isn't correct or the better way:)

EDIT: If you discomment that line above.You're camera will actually fly:)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!