How I got my game running on Android
Welcome to my "How I" series of blog posts. This series will follow my game dev journey and chronicle how I got different aspects of my games working. I've gone with "How I" rather than a tutorial series as I still have no idea what I'm doing and I'm sure there are better ways of doing a lot of these things. Hopefully it will help some people out there working through their own development and I might get some tips and tricks on how I could've done things better too - win win. I intend to link to the learning resources I used on my journey too which will hopefully be of even more use than my blog posts themselves.
Enough of the waffle. Let's get stuck in!
Firstly, the downloads and installations. In the project settings for my game I switched the build platform to android. If you don't see android here as an option you will also have to download that SDK. I also installed the Device Simulator package (I don't think this is necessary for it to run on phones but it sure helps with testing), the Input System manager and the Cinemachine package.
Next up a little snippet of code to get touch input working. In my case all I needed was which side of the screen was touched so I could the move my game objects accordingly. I almost forgot, to use the input system I had "using UnityEngine.InputSystem;" at the top of this script. This system can get much more complicated quite quickly as you delve further in to it. If like me you enjoy watching other people figure these things out Ben @ RespawnPressUp worked through some of the more complicated ways of using the new input system with touch screens.
Once that was done I set up my canvas and camera views to make sure they fit to multiple different screen sizes. Testing this is where the device simulator came in super handy. I used what I think is a pretty standard screen resolution for mobile devices and set it to "Scale With Screen Size". For the camera view screen size Cinemachine was a godsend as I had given myself multiple headaches trying to figure this out previously. Now it's as easy as creating a target group camera and placing game objects at my absolute screen bounds and adding them to the target list.
Last but not least I built my build (is that right?) to my phone. I started by putting my phone in developer mode by tapping on 'about phone' in *settings* 7 times. Then with my phone connected by USB I simply hit 'build and run' and lo and behold, we're running on a phone.
As a big handheld console fan, playing this early build on my phone was one of the most satisfying things I've achieved in game dev to date.
Let me know if you enjoyed this read or if you've got suggestions for things I could improve on. Hopefully there'll be more of this in the not too distant future.
Tutorials and further learning:
- Pretty much everything I needed for this I learned from the @Gamedev.tv "Unity C# Mobile Game Development" course over on Udemy
- Ben working with the new input system on Twitch https://www.twitch.tv/videos/1150972185 (@RespawnPressUp)
Comments
Post a Comment