Search Unity

joystick buttons initial state not recognized?

Discussion in 'Scripting' started by mtpzone, Sep 15, 2016.

  1. mtpzone

    mtpzone

    Joined:
    Dec 7, 2013
    Posts:
    3
    During Start or Update the initial state of any buttons on a joystick are not recognized.

    Code (CSharp):
    1. if(Input.GetMouseButton(0))
    2. {
    3. Debug.Log("mouseButton");
    4. }
    will print "mousebutton" from the first frame the game starts if you are holding the mouse button down.
    however

    Code (CSharp):
    1.  
    2. if(Input.GetButton("button 0"))
    3. {
    4. Debug.Log("joystick trigger");
    5. }
    6.  
    will not print anything if you are holding it when the game starts. You have to let it go and then pull it again to get it to see that the button was pressed. I can not start the game with the trigger pulled and have it be recognized. I need to setup a series of toggle switches during "Start" based on how the joysticks extra buttons are set. but I can not get it to read them until they are at least pressed once.
    after that the toggle buttons or momentary buttons are all read just fine.. but there initial state is not recognized.
    anyone come across this?
     
    Last edited: Sep 15, 2016