Input.GetAxis(...) * Time.deltaTime Still giving different values dependent on framerate.

Im using Input.GetAxis(“Mouse X”) * Time.deltaTime to add weapon sway but it still changes dependent on framerate. At low fps ~15, the weapon sway is large, At high fps ~120 the weapon sway is very slight.

I thought multiplying the Input by Time.deltaTime is meant to resolve this type of thing?

Anyone else had an issue like this?

Thanks

  • Matt

It is literally the time passed since last frame. If fps is 15 deltaTime will be ~1/15. At 120 fps 1/120, assuming the framerate is consistent. You are multiplying your mouse input by this value.

1 Answer

1

Well, you are describing the expected result.
Low frame rate will create a large value but because you have less frame per second in the end the values are close to equal.

fps   dt     movement  pre frame       after 1s

50    0.02   20        20*0.02 = 0.4   0.4*50 = 20
100   0.01   20        20*0.01 = 0.2   0.2*100 = 20

You want your guy to move 20 per second and that is what it does. But the movement per frame is twice as big in the slow fps.