GamePad Support w/ New Unity Input System

Jordan Evans
3 min readFeb 16, 2022

With games nowadays, we need to consider applying gameplay functionality for multiple different devices. Some people may enjoy it more with a mouse and keyboard feel, while others prefer using a controller. The task itself for implementing a controller option is really simple when it comes to the new input system. All that is really required is to just apply the buttons you want to have the controller set to as another option for the movement in the game under the action maps:

As we can see, we can simply just place the controls we want to use for a gamepad within the actual actions we have already created. We can go further and set them up so that they are within their own control scheme as well, to make it easier to see if we have all of the controls placed for each of the actions we wish to use:

Once we get all of the gamepad controls sets up to how we would like it, we now need to look into how we can go about changing the UI in the game to let the user know which button to press to interact with the objects. The method I ended up taking is a simple button option upon launch of the game. The button that gets picked will determine which of the controllers the player wishes to play with, and will change the UI to display the button needed to interact with the object:

Once the player chooses his controls, we need to make sure that both of these options disappear from the screen, along with telling the method we will be making what value we want it to be:

As for the method we are calling, it is a simple value check method that will set our int to either a 0 or a 1:

Finally, we can simply go into our UI portion of the script and add in the following:

With this code, we are letting Unity know that, in this case, if the value is 0, the controls we want displayed are for the keyboard. If the value is a 1, we want the controls to be displayed for a PS4 controller. With this all set up, let’s take a look at how it is within the game:

And for the PS4 controller:

There we have it, we have added in the functionality for a controller, along with adding in a little button to let the user know which button will be required to interact with our objects.