Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Messed up output from steering wheel controller/joystick

Discussion in 'Scripting' started by BL4CKF0X, Jan 15, 2019.

  1. BL4CKF0X

    BL4CKF0X

    Joined:
    Jan 8, 2019
    Posts:
    8
    Hello everybody,

    I'm currently trying to write a program for a driving simulator, but I can't figure out how to get the correct output from my steering wheel so that it outputs 0 when it's centered, -1 when turning full left and 1 when turning full right.

    I tried to set up the axis in "Project Settings -> Input" with a sensitivity of 1. This results in left turns just outputting 1, then suddenly outputting -1 when it's completely straight followed by decimals ranging to 1 on a full right turn.

    I played around with the sensitivity, trying to get better results. At around 0.05 sensitivity, the output reacts to left turns, but I get weird jumps when the steering wheel is about straight and completely right.

    Using windows' internal game controller test window, the steering wheel worked perfectly fine. But that window doesn't show me the specific output, just a simple graphical representation.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    What does the code look like that's capturing the input? You're using Input.GetAxis?
     
  3. BL4CKF0X

    BL4CKF0X

    Joined:
    Jan 8, 2019
    Posts:
    8
    Yes, I tried both Input.GetAxis and Input.GetAxisRaw.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    The lower sensitivity definitely seems like the better way to go. Have you tried playing with the "Dead" value of the input? Some controllers are pretty noisy around the center, so a higher "Dead" value (like .1 or .2) might be necessary.
     
  5. BL4CKF0X

    BL4CKF0X

    Joined:
    Jan 8, 2019
    Posts:
    8
    I'm going to try that tomorrow. I'll keep you updated. Although I don't see how that will change the fact that theentire bandwith seems to be only connected to right turns. It's so bizarre.
     
  6. BL4CKF0X

    BL4CKF0X

    Joined:
    Jan 8, 2019
    Posts:
    8
    This is so weird. I had the sensitivity around 0,05 and dead at 0,1 as you suggested. Suddenly turning right gave me no output and turning left gave me weird output.

    I now have the steering at 0,01 dead and 0,05 sensitivity. The result is the following:

    Full left at 0,6468594.
    Relatively smooth transitions until about 5° left.
    Then at the center a sudden jump from 0,1747621 to -0,04040404.
    At about 170° right it's 0 until about 200° right.
    Full right at positive 0,04040404.

    It now seems the dead is between 170° and 200° right?
     
  7. BL4CKF0X

    BL4CKF0X

    Joined:
    Jan 8, 2019
    Posts:
    8
    I reposted my question with a better explanation of the problem.