Jump to content
  • Advertisement
Sign in to follow this  
sbetchel

Simple moving forward and backward - FPS cam

This topic is 2756 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

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
Advertisement
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
If you know the 'yaw' angle of your camera object, you can compute the 'ground plane' forward vector directly from that angle.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!