Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I multiply the mouse movement by a given number to get camera rotation of a desired speed. But it only works at 60 FPS. When I don't limit the frame rate I get around 350 FPS and the camera rotation is significantly too slow.

In my calculation, I already consider the frame time.

rotateCamera(ivec2 deltaMouse, float deltaTime, float sensitivity)
{
    // apply multipliers
    deltaMouse *= deltaTime;
    deltaMouse *= sensitivity;

    // rotate camera by deltaMouse
    // ...
}

Is this approach wrong? Why isn't the mouse movement independent from the frame rate in my code? How to achieve that?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Where's deltaMouse coming from? If the API you're using is giving you translation units like pixels or centimeters, you shouldn't scale by deltaTime. Moving your mouse 1 cm should rotate the camera by, say, 15 degrees, regardless of how many frames or how long it took to move that 1 cm.

share|improve this answer
    
I do not use a high level API. However, your answer is correct. The rotation shouldn't depend on the time at all. –  danijar May 12 '13 at 11:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.