Jump to content
  • Advertisement
Sign in to follow this  
bpx95

First Person Camera Proper Mouse Input

This topic is 2530 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 am wondering the best way to retrieve and handle mouse input for a first person camera. The idea is that the speed at which the camera turns does not depend on frame rate, i.e. 30 FPS plays the same as 1000 FPS.

One way to do this:

Record cursor position each frame
Reset cursor position to middle of window each frame
Scale that by some constant

Theoretically, this would produce constant camera speed, because the mouse would move more each frame at a lower frame rate, and move less at a higher frame rate. However, this doesn't work because at high frame rates, it is very possible that the cursor will move less than a pixel each frame, and you would get no movement.

How do you implement first person cameras?

If you use the mentioned method, how do you get around the flaws?

Share this post


Link to post
Share on other sites
Advertisement
If the application is windowed, you have to reset the cursor, else, you can just read in the raw mouse coordinates, and use those against the old values to find the delta values to use.

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!