Cross-Platform Input Controller!

addam davis
3 min readDec 20, 2021

Objective: Create input controls for mobile/pc!

In this tutorial we are going to set up our cross-platform controls. With cross-platform controls we will be able to build a playable version of our mobile game.

The first step is to open the Unity Asset Store by going to Windows> Asset Store

We need to search for “Unity Standard Assets”

Select Import and a window will appear.

The only thing we need here is the cross-platform input.

This will add all the corresponding assets to your project view.

Select the Mobile Single Stick Control and drag it into the Hierarchy.

This adds two objects to your game, a joystick and a button.

We need two buttons, once for jumping and one for attacking. Duplicate the jump button then rename them A button and b button. Resize and place the buttons where you want them.

Now all that is left is to connect these buttons and joystick through code. Open the player’s script.

In the movement method we need to comment out our old input method and use the cross-platform input manager.

We need to use the Cross-Platform Input Manager for jumping and attacking as well.

In the inspector for the A and B button, under the button handler script we need to name the buttons appropriately.

Now we are ready to test our buttons in the editor!

Now our game has mobile controls. We are ready to make our first build of our game for our phones. Don’t be afraid to experiment with your button layout and I’ll see you in the next tutorial!

--

--