Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Using both new and old input gives unexpected vertical behaviour

Discussion in 'Input System' started by RainerEngblom, Mar 2, 2023.

  1. RainerEngblom

    RainerEngblom

    Joined:
    Sep 10, 2020
    Posts:
    9
    Ok, this is driving me crazy.
    I'm making a split screen 2D-dogfight game and trying out different controllers for it. The new input system works like a charm for PS4-controllers, but now I'm testing a standard usb-joystick (Thrustmaster) on my MacBook Pro.
    The new input system does not recognize it as a game controller, so I use the old input system for it.
    "Horizontal" and "Fire1" work fine with my joystick. The ship rotates clockwise and counter clockwise as expected, and shoots with main weapon.
    My "Vertical" controls the thrust and secondary weapon, and it gives correct values between -1 an 1, but when it gives 0 (zero) for "Vertical" it still behaves like I'm pulling the stick back.
    Here's my configuration for the axis. As you can see I've set the dead zone really high, but it still fails.

    Screenshot 2023-03-02 at 16.19.43.png


    So, the Debug.Log shows the value is zero, but it still goes into the if(thrust < 0) block and shoots the secondary weapon all the time. I even tried printing out thrust*100 but that still gave zero.
    EDIT: I also tried Debug.Log(thrust.ToString()) but it also gives a blank zero.

    Code (CSharp):
    1. thrust = Input.GetAxis("Vertical");
    2.             if(thrust<-0.5f)
    3.             {
    4.                 Debug.Log(thrust); //Here debug shows thrust=0
    5.              
    6.                 ShootSecondary();
    7.              
    8.             }
    Thank you for any suggestions or insight with this.
     
    Last edited: Mar 2, 2023
  2. RainerEngblom

    RainerEngblom

    Joined:
    Sep 10, 2020
    Posts:
    9
    Ok, I restarted Unity and now it works as expected.