Cross-platform Input Controller

2D Mobile Game

Objective: Import and merge cross-platform input controller in the game

First of all, go to unity asset store and add the Standard Assets to your assets and sign in to the same g-mail in Unity.

Inside Unity, go to Windows>Package Manager and Import the Standard assets from the My Assets Package.

Now drag the Mobile Single Stick Controller to your scene from the package.

Add the UnityStandardAssets.CrossPlatformInput namespace to start implementing the crossplatforminput in the game.

Now create a gameobject variable and assign the joystick to the variable.

Add this script in replacing Input.GetButtonDown for player attack

Now replace the Input.GetKeyDown(KeyCode.Space) with above script to allow the player jump.

Finally replace Input.GetAxisRaw(“Horizontal”) with the above script to allow player movement.

And this is the final result.

--

--

--

Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

100DaysOfCode — Halfway There

On the Rocks with Owen Astrachan, Expert Witness in Google v. Oracle

Django migrations, how to solve a nightmare!

Exploring the Python Universe Part 1

Makers Academy W8 D2: Spring is coming

Our team ⚡️ ACV | ORANGE SKIES⚡️collator of the Moonbeam community congrats to all winners giveaway…

What is a PLC(Programable Logic Controller)?

Building Docker Images — Advanced

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niraj Karki

Niraj Karki

Unity Developer

More from Medium

Creating a Sci-fi Lab Room

Creating Character Animations in Timeline and Tackling Some Known Issues

Light her up — Adding emissions to your game objects using photoshop and blender

Tap & Hold & Rapid Prototyping w/ New Unity Input System