Sunday, September 6, 2015

Unity Touch Joysticks Tutorial - Touch Input 2D Spaceship Controller

In this Unity C# Touch Tutorial we create a touch joystick and button in Unity 5 and use it to control a floaty spaceship.

Download the project below the video

Time Breakdown:
1:07 - Importing CrossPlatformInput from the Standard Assets
2:23 - Adding the joystick to our scene and setting up all the other requirements
3:20 - Fixing the Joystick start position so it doesn't snap to the bottom corner of the screen
4:13 - Clamping our joystick movement to a circle rather than a square
6:45 - Setting up the player spaceship in Unity
8:25 - Starting the spaceship player controller script
9:53 - How to read the joystick data from the CrossPlatformInputManager
13:10 - Using a conditional operator to apply boost speed
14:45 - Adding linear drag to slow down like Asteroids
15:45 - Adding Canvas Scalar component so the GUI stays on screen
16:20 - Build and demonstration on Android

Check out the video above to hear the explanation and see the code in action.

You can download a package for this project from Google Drive: