Unity thinks I'm holding up and left on a joystick
So since this has been happening for a while to all the unity games that I have bought from steam, where the character would just walk forward and left without my input, I decided to open up Unity Editor and make a scene with a ball in it and make it roll according to the user input, and then I wrote the code to output to the console whether the user is pressing left, right, up or down:
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
string s = "";
if (moveHorizontal == 1)
s += "right";
else if (moveHorizontal == -1)
s += "left";
else
s += "none";
if (moveVertical == 1)
s += ", up";
else if (moveVertical == -1)
s += ", down";
else
s += ", none";
Debug.Log (s);
And sure enough, the Console outputs: "left, up" and the ball rolls forward and to the left whenever I'm not holding any buttons.
I found out that it's the second Horizontal and Vertical Axes in the input manager that's causing it, which is the horizontal and vertical axes on a controller.
I have no idea how to solve this problem without disabling those inputs, and also why this is carrying through to any Unity-made steam games that I've bought. If anyone could help, that would be great.
Something is up with your controller by the sound of it. What kind of controller? Try to reinstall or update its drivers. If it has a diagnostic utility then check that out. I had similar happen with my logitech controller and just threw it out because it was junk.
Answer by TacoMakerMan · Nov 14, 2016 at 11:12 PM
Okay so, I decided to go into my device manager, disable all of my controller drivers and restart my computer, and the problem went away, so I re-enabled them one by one and found out that is was being caused by a driver called "HID-Compliant game controller."
I don't know why this was causing a problem but it worked anyway.
Answer by UNDERHILL · Nov 15, 2016 at 06:16 AM
Historically in the computing world, sometimes, if you have your controller stick pressed in a direction when you plug it in or boot sometimes this will cause issues with the startup calibration (if any) and it will constantly seem to be in action though the sticks are in center.
Answer by bbonard · Dec 07, 2021 at 08:40 AM
Thanks a lot @TacoMakerMan for this thread and answer, I had exactly the same issue and did not tackle it before starting making a game...
I think it would be interesting to make the game more resilient on those kind of issues. But as a noob, I don't really know how.
Would it be possible to blacklist all inputs by default and create a whitelist of those you want ? Whitelist that could be updated in a "controls" menu section ?