- Home /
GetButton("Joy_button0") will not return true on startup.
I have a custom controller that uses a BU0836X Joystick board.
One of the buttons on the joystick is a kill switch that can lock in a upstate (true) or in a downstate (false). I want to get the initial position of the button when the game is launched, it can be up or down. Here is my code:
function Start () {
eStop = Input.GetButton("Joy_button0");
print(eStop);
}
When the button is down/false I should get false which works just fine. When the button is up/true I should get true but I am always getting false.
When the run Input.GetButton("Joy_button0") from Update() I also get false initially regardless of actual button state. But if I hit the button down/false and release to up/true I then get true which is the expected result.
Anyone know why the button is mapping to false initially? and how can I get the correct state of the button on game launch?
Thanks very much.
I have basically the same problem, did you manage to solve yours?
The problem I was having was when switching scenes the Input.GetButton got reset. I tried with Input.GetAxis as well. The value was 1 on the previous scene, and on the Start() of the script on the new scene, Input.GetAxis returned 0.
But later, I built my project and ran it on the iPad, in my case I am doing an iPad app. On the iPad this doesn't happen, the Input manages to preserve its buttons states. So for me, my problem was only on Unity Editor, thus it's not the worst thing ever.
vitor - I have not resolved the problem. It is interesting that your problem disappears when you run the build of the project. $$anonymous$$ine unfortunately does not go away. But I am building for windows.
Gerry$$anonymous$$ - I changed the 'Type' in the input manager to 'Joystick Axis' from '$$anonymous$$ey or $$anonymous$$ouse Button'. I still get the same true/false values from the joystick button. Is that how you would map a button to an axis? Any other ideas?
Your answer
![](https://koobas.hobune.stream/wayback/20220613083922im_/https://answers.unity.com/themes/thub/images/avi.jpg)