Search Unity

desperately need help setting up joystick sensitivity

Discussion in 'Input System' started by mattlewis83, Oct 12, 2021.

  1. mattlewis83

    mattlewis83

    Joined:
    Jul 3, 2013
    Posts:
    6
    We have tried everything we can think of with the new input system and haven't found a solution that behaves how we expect.
    We would like to adjust joystick sensitivity without dulling the top speed.
    The real issue is the initial speed the player starts at just after the stick exits the deadzone and begins to read input. That initial speed is just far too high and doesn't work for the game we are making and makes things feel very twitchy. Speed should be very slow and gradual at first, split the difference once the stick is half way pressed, and go full speed once the stick is fully pressed. For example, say the deadzone is 0.925. At stick rest it's at 0. Once the stick is pressed to 0.926 the speed currently is a 3 out of 10. we want that speed to start at a 1. How can I adjust this initial starting value for speed?
     
  2. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    If it truly is just a matter of remapping 3-10 to 1-10 then you can do so in code via a linear interpolation such as:

    Code (CSharp):
    1. //Get percentage of speed on 3-10 scale
    2. float linearParam = Mathf.InverseLerp(3f,10f,currentSpeed);
    3. //Apply percentage to 1-10 scale
    4. float finalSpeed = Mathf.Lerp(1f,10f,linearParam);
    Otherwise you'd have to give more specifics, such as how you are reading the input, where it gets turned into speed, and how it transforms on the way to your movement code. It sounds like there's a part of your input handling code which is being overlooked if you're seeing arbitrary numbers such as "speed 3" pop up in your testing without knowing how to adjust the sensitivity.