Unity Cross Platform Input

Ryan Sweigart
Nerd For Tech
Published in
Aug 10, 2021

Objective: Use the Unity Standard Asset’s Cross Platform Input system.

So far, we’ve been creating our game for the Windows platform. But this is meant to be a mobile game. We can set the controls for mobile with the Standard Asset’s Cross Platform Input system!

First we have to include the CrossPlatformInput library in our Player script.

Now we’ll have to change our movement code to use the input system. The Cross Platform Input system won’t break our previous code.

We’ll do the same for our jump button…

…and the Attack button.

We must also make sure our button’s Button Handler scripts point to the correct axes. In our case, the Jump Button should point to Jump, while the Attack Button should point to Fire1. Now when we export our game to mobile, we’ll have touch controls!

--

--