I’m currently working on a game where I need to read in multiple inputs. I’m currently targetting the users to use a joystick when playing. What I need to do is execute a particular action when a particular input was pressed. For example,
if ( Input.GetButtonDown( "A" ) )
{
//Do action A
}
else if (Input.GetButtonDown( "B" ) )
{
//Do action B
}
......
Having 8 if statements (assuming I’m using the X A B Y button and the joysticks), is not great, but is accectable. It becomes an issue when I can combine these buttons to do a completely new action.
if(Input.GetButtonDown( "B" ) && Input.GetButtonDown( "A" )
{
//Do another action AB
}
And currently I have 16 possible actions, but this can grow. Having 16+ if statements is not only ugly but hard to maintain. I was wondering if there is a better way to get multiple inputs.