Formula for Input.GetAxis

I’ve been struggling for days trying to find the formula Input.GetAxis uses to calculate its return value. If I were to create an Input.GetAxis replica (which in fact I am), how would I calculate the return value based on some parameters:

  • sensibility (float)
  • Gravity (float)
  • positive axis key (KeyCode)
  • negative axis key (KeyCode)
  • Dead (float)

In my code, when I press the positive axis key and hold it, Input.GetAxis returns (in FixedUpdate) a number like 0.1892838 then this number increases (seems randomly) until reaches 1. I know that the returned value is not random (is it?). What is the formula Input.GetAxis uses to calculate the value?

No one besides a Unity engineer who worked on it can give you the exact formula because Unity isn’t open source. You can only attempt to mimic it, but you’ll see after some time that you just can’t. It is still interesting why you’re trying to rewrite the input system to make it better while trying to copy Unity’s input system from the ground up, though.