Setting up 2 players

Hurry Hurry Heal Me would be no fun if it was only 1 player, so I now need to make sure that I can have 2 controllers moving 2 separate players.

Screen Recording The Process

The Input Manager

Edit > Project Settings > Input

Is where most of the magic takes place. But before we start adding in inputs it is useful to know a little about how Unity keeps track of different controllers.


Is the function needed to know which Joystick Unity has mapped to the Joy Num. Now Input.GetJoystickNames is actually a string with all the information (names) of the controllers that Unity can see, but this is not the Joy Num. The Joy Num is the number that the controller appears in the GetJoystickName list (array). So to find this out, you need to run a little function.


This function returns something like this in the Debug Console. I was able to tell which was the ps4 controller and the xBo350 controller by plugging them in one at a time.

Showing that:

  • 47 = joystick 1
  • 32 = joystick 2

Screen Shot 2017-02-15 at 13.54.32.png

Player Movement Script

A few changes need to be made to the player movement script as I now want to specify which controller I want to use (rather than taking any input I give it).

I add a public string = controller;


This allows me to type into Unity the controller I am using for that player.


I now need to change the string I used to get the input to include my controller sting



So now my FixedUpdate looks something like this:

  • I have added “X” , “Y”, “Run” to the end of the controller string as I have different inputs for each of these variables, which needs to be mapped in the Input Manager.


Back to the Input Manager

Now that we can distinguish the controls for the two players, we need to show this in the input manager.

  • This means creating a load of xBox360 inputs and ps4 inputs.
  • As we know which controller is which JoyStick number we can add it here as well
  • If you have buttons you need to make sure you specify which JoyStick you are using as well.
  • Note that I could have called xBox360 anything as long as under the controller String I have called it the same.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s