1
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ I do not use a high level API. However, your answer is correct. The rotation shouldn't depend on the time at all. \$\endgroup\$
    – danijar
    Commented May 12, 2013 at 11:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .