GameDevHQ Crash Course #37 Multi-Platform Controls

Jason Dixon
2 min readMay 2, 2021

--

Making a control scheme that works on both PC and Mobile is very easy in unity, they provide a nice set of customisable default tools that are easy to use.

Navigate your way over to the Unity Asset Store(https://assetstore.unity.com) I have linked directly to the Standard Assets that you can use. This is a free asset from Unity.

With that added to your account head back to Unity and in your package manager add the Standard Assets to your project, you may need to refresh the package manager if it is not automatically updated.

With that added to your project you will see a folder in your assets called Standard Assets, for what we want navigate down to CrossPlatformInput->Prefabs, in here for my project I am going to be adding the MobileSingleStickControls as I am using a left stick plus buttons on the right.

You should now have the Joystick plus Jump button added to your scene.

You can multiply the Jump button if you wish to add more buttons that you can use, my game has 2 usable buttons.

With that done we replace the image components with or game assets and name them accordingly.

With them named you will see in the inspector that there are event trigger names, these correspond with what you have named your buttons.

Now in our code we can bring this all together. For our joystick movement we change our Input.GetAxisRaw to CrossPlatformInputManager and we have successfully changed our movement to the joystick we implemented earlier.

For our Buttons we change Input.GetButtonDown to CrossPlatformInputManager or we can add a || and add it as an additional so you can use it on both platforms. And we use the name of the button we used earlier to trigger the button.

Now our controls work on both platforms.

--

--

No responses yet