Day 107 — Preparing a 2D Unity Game for Android Development
Hey and welcome!
Now that we’re good and familiar with Tilemap it’s time that we start putting together this game by getting it ready for Android development and adding in our Player to get them ready for us to implement some movement for them.
Let’s start with looking at how to get our project ready for Android. Head on over to File > Build Settings and choose the Android option and then click on Switch Platform if you get an error along the lines of “Unable to find suitable JDK installation” then there’s one extra step for you to do here, if you don’t then all you need to do is wait for this to process which may take some time.
If you do need Java Development Kit you can download it at the following link for the operating system that you’re using:
Java SE Development Kit 8 Downloads
Your search did not match any results. We suggest you try the following to help find what you're looking for: Check the…
If you downloaded the same asset package from Filebase that I did you’ll find a Game scene in the _Scenes folder that will give you a full level to work with that was made using the assets provided.
If you don’t have this I recommend expanding out what you’ve created so far in order to give yourself some more room to work with.
Now let’s go set an ideal aspect ratio for our game so that it will look ideal on a mobile device. In your game tab you’ll see a dropdown that currently has Free Aspect set as the choice, go ahead and click on that and then choose the 16:9 Landscape option and you’ll have the ideal ratio for our game on mobile.
Depending on the version of Unity you have you may not see the 16:9 Landscape option, if that’s the case then you can click on plus Icon at the bottom of the list to add in a custom one. Set the Label as 16:9 Landscape, the Type as Aspect Ratio and then change the Width & Height to 16 and 9 and you’ll be all set here.
Setting up the Player
Let’s look into getting our Player set up now. Under Official_Game > Sprites > Characters > Player in your project files you’ll find a bunch of player sprites that will need slicing, for these ones make sure you slice them by 256 x 256 otherwise your animations may look off! These are all going to be animations so make sure to have a look through them when you’re done slicing so that you’re happy with the result.
When you’ve sorted out all of these animations go ahead and drag and drop the Idle_0 sprite over into your hierarchy and call this object Sprite. Next, create an empty game object making sure that it’s position is 0, 0, 0 and then call this object Player and drag and drop the Sprite object into this. This will make things a bit easier for us to work with as we’ll be adding quite a few components to our player so this let’s us access the Sprite Renderer quickly.
Last thing to do is to set the Order In Layer for your Sprite object to 50 or anything higher than 29 so that it’s in front of every layer.
With all that done you’ll be ready to start implementing some functionality to the player in the next article!