# 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.

## 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 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:)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634134
• Total Posts
3015751
×