Mobile input/touch control for your Unity game

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello fantastic people I hope you are doing great from the very beginning I knew that one but dwarf will be a mobile game it is a little bit scary as I never published anything for this type of platform the part that I was the most worried about is handling player input however it turns out that the input system package makes it extremely easy let me show you here I have this little elf he can walk and the jump the way the script is written doesn't really matter the most important thing is that it uses the new input system if you would like to check if it's installed you can go to window package manager and then search for the input system in the unity registry if the package is installed you will see a remove button in the right bottom corner if you haven't worked with the new input system you may want to check those two tutorials here I have my simple input action asset it has just two actions walk and jump both of them have two bindings the relevant ones are the GamePad in puts as those will be used by mobile so for the walk I selected the left stick and for jump the South button now in the hierarchy I create new UI image I double click on the canvas to zoom out a little bit then I set the Anchor Point of the image to the left bottom corner and adjust its position the image will become my joystick so it is quite important that it's located far enough from the edges the input package comes with on-screen stick and on-screen buttons components for now I'm going to use the first one for the control path I select the left Gamepad stick you will not believe but it's all we had to do let's test it out fantastic let's make it look a little bit nicer first I select a nice Sprite then of course I need to adjust its size I don't want it to be too invasive so I'm going to decrease the alpha using the color setting on the image this will make it semi-transparent [Music] awesome time to add the jump button I add another image and change its Anchor Point to the right bottom corner then I add adjust its position add a nice Sprite to it and of course make it semi-transparent now it's time to add to it the on-screen button component for the control path I select the GamePad self button I rename the button and add another image as its child this time I'm using the arrow Sprite Which will indicate nicely the jumping action I add just its Alpha and then play a little bit with the size of the button and the arrow I want to make sure it is big enough so it's easy to use but at the same time that it is not too invasive let's test it out fantastic let's now create a very small script which will allow us to show the inputs only on mobile platforms I create a new script and call it show on mobile I assign this script to the canvas and open it I use the set active method on the underlying game object for the value I use the application.is mobile platform the best thing about it is that it will work correctly even on the webgl bills if you enjoyed this little tutorial don't forget to share it with your friends and of course subscribe to my channel and most importantly have a fantastic day love you and bye bye
Info
Channel: PitiIT
Views: 47,440
Rating: undefined out of 5
Keywords: unity 2d, unity tutorial, unity mobile, mobie game unity, unity touch input, touch input, handling touch input, mobile controls, mobile control, input on mobile, input on mobile unity, touch input in unity, touch input with input system, input system package, new input system package, touch input unity, mobile, mobile input, mobile input unity, mobile input unity game, 2d mobile input, on screen stick, on screen stick unity, mobile pad unity, mobile button unity
Id: NqrJHj9xlqY
Channel Id: undefined
Length: 3min 44sec (224 seconds)
Published: Fri Oct 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.