Jump to content
  • Advertisement
Sign in to follow this  
SakoEBS

First Person Shooter Camera Question

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

I apologize if this is a frequently asked question. I'm working on an augmented reality project that uses sensors to orient and position the camera. The GPS isn't always accurate and that can be annoying while testing! Anyways, I'm working a d'pad solution so that I can move the camera through the augmented world to test various objects and interactions. I have a forward and d'pad direction vector, but I'm not sure how to use them to update the position of the camera.

Orientation is represented as a quaternion. I can easily pull a normalized forward vector from the quaternion. If I add the forward vector to the camera position the camera moves in the direction the camera is oriented (aka forward). This is great, but I want to strafe and move backwards.

I implemented a touch screen d'pad that outputs a normalized vector (x = -1 to 1, y = 0, z = -1 to 1). If I add the d'pad direction vector the camera position the camera moves along the x and z axis. This is good, but I want to move in the direction of the camera.

How do I use the forward vector and d'pad vector to update only the position of the camera (not orientation)? Am I missing something?

Share this post


Link to post
Share on other sites
Advertisement

I apologize if this is a frequently asked question. I'm working on an augmented reality project that uses sensors to orient and position the camera. The GPS isn't always accurate and that can be annoying while testing! Anyways, I'm working a d'pad solution so that I can move the camera through the augmented world to test various objects and interactions. I have a forward and d'pad direction vector, but I'm not sure how to use them to update the position of the camera.

Orientation is represented as a quaternion. I can easily pull a normalized forward vector from the quaternion. If I add the forward vector to the camera position the camera moves in the direction the camera is oriented (aka forward). This is great, but I want to strafe and move backwards.

I implemented a touch screen d'pad that outputs a normalized vector (x = -1 to 1, y = 0, z = -1 to 1). If I add the d'pad direction vector the camera position the camera moves along the x and z axis. This is good, but I want to move in the direction of the camera.

How do I use the forward vector and d'pad vector to update only the position of the camera (not orientation)? Am I missing something?


What you need to do is exactly what you are doing in number 1. Get the forward vector from your orientation(quats in your case), and use the value from your d pad to scale that vector to add to your position. Same thing for strafe


position+= forward * dpad.z + right * dpad.x


now if you push up you move forward, and if you push down, dpad.z is negative and you move backwards. If you dont push dpad at all, then z==0 & x==0 and your position wont change

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.

GameDev.net 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!