Jump to content
  • Advertisement
Sign in to follow this  
k0lpA

FPS mouse view problem with framerate

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

hey guys, im making a little first person shooter in C++ with GL and Ive got a problem with the mouse view.

I reset the mouse position to 400/300 (center of my 800x600 win) every frame and check how much it moved and rotate the camera acordingly, that works great.


if(engine.mouse.x>400)
game.camRot.x += MOUSESPEED*float(engine.mouse.x-400);


if(engine.mouse.x<400)
game.camRot.x -= MOUSESPEED*float(400-engine.mouse.x);


if(engine.mouse.y>300)
{
game.camRot.z += MOUSESPEED*float(engine.mouse.y-300);
if(game.camRot.z > 90) game.camRot.z = 90;
}

if(engine.mouse.y<300)
{
game.camRot.z -= MOUSESPEED*float(300-engine.mouse.y);
if(game.camRot.z < -90) game.camRot.z = -90;
}

SetCursorPos(400,300);


engine.mouse and game.camRot are floats
MOUSESPEED = 0.17

the problem is, the mouse speed is dependant on the framerate... even tho it shouldnt
when moving objects I multiply their movement by 'deltaTime' so that they go faster if the framerate is lower.
but for the mouse I want it to always move at the same speed so that if I move 1inch on my mouse pad the view always rotate the same amount independant of the framerate.
I can't find whats wrong with my code, but the mouse is always slower when the framerate goes down, and multiplying by 'deltaTime' makes it even less stable.

Share this post


Link to post
Share on other sites
Advertisement
Might have something to do with the way you implemented your gameloop. Adjusting the speed of your gameplay based on the FPS of the client can cause your game to be unstable because of the way a computer has to round float values.

You may want to check this out :
http://www.koonsolo....tters-gameloop/


Of course i am just assuming here because i have no idea how the rest of the game is programmed.

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!