Sign in to follow this  
sbetchel

Simple moving forward and backward - FPS cam

Recommended Posts

Hi all. I have set up a mouse look style FPS cam for my scene using OpenGL. Basically I am needing to know how to move the camera forward and back but also stay on the ground as a player would.

Right now, when I move forward and back, I move along the Z axis of the camera. This works for a "flying" camera but not to stay on the ground. I cant use the world Z axis because that moves me the same direction no matter which way I face. Can anyone shed some light on how this is typically done?

My first thought was to get the parallel projection vector by projecting my camera's Z axis onto the ground and translating using that. Don't know if that is correct though. Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by sbetchel
Hi all. I have set up a mouse look style FPS cam for my scene using OpenGL. Basically I am needing to know how to move the camera forward and back but also stay on the ground as a player would.

Right now, when I move forward and back, I move along the Z axis of the camera. This works for a "flying" camera but not to stay on the ground. I cant use the world Z axis because that moves me the same direction no matter which way I face. Can anyone shed some light on how this is typically done?

My first thought was to get the parallel projection vector by projecting my camera's Z axis onto the ground and translating using that. Don't know if that is correct though. Thanks!


projecting the cameras vector is one way, or you could just take a copy of the cameras forward (or z) vector , set its y component to 0 and renormalize it.

Share this post


Link to post
Share on other sites
It sounds like your camera movement is the player movement. You may want to decouple the camera from the player, in the sense that the camera can be rotated independently of the player. After all, you can walk forward and look to the side at the same time. In a first-person shooter, that can be a nice feature.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this