So, a question we get asked a lot is how to make a 2D game? Of course, this is a huge question to answer. But, hopefully, this video should help point you in the right direction. And this is actually filmed on our brand-new video camera. So, I hope the quality is all right. Apparently, this camera has a pretty narrow lens. So, we had to do this crazy setup to make it work. Luckily, making 2D games in Unity has gotten so much easier over the last couple of years Ever since they introduced the new 2D features in version 4.3 We've seen a bunch of cool features and workflows for different aspects of working with 2D in Unity Now, 2d games, of course, come in a variety of different art styles and genres. And the tools that are right for you are going to completely depend on the game that you're making. But, in general, we can split Unity up into two primary workflows. Tile based. And sprite based. The tile based workflow is meant for games that are build on a grid As the name suggests You create environments by placing tiles. Which makes it pretty fast and easy to create and modify levels. The sprite based workflow, on the other hand, gives you more control As it simply means that you place object freely in the world As a result of this you can create more detailed and dynamic environments. But it might not be as quick. And, on top of that, Unity is also working on some tools for vector graphics In case you are really fond of illustrator. But, regardless of what workflow you choose We first have to create a project. So, to create a new project, we go "new" And your UI might look a tiny bit different here But that's because I'm using Unity hub Which is still in beta But the idea should be the same We then select a name for our project I'm just gonna call mine "2D Game Example". We then select a Unity version. I'm gonna be using 2018.2 Then we chose a save location I'll just use my projects folder And, finally, as our template, we want to make sure that we select 2D. Let's then hit create project And Unity is going to open up a new empty project. And, now, we can see we have this empty scene With only a main camera in it. And because we made sure to select 2d as the template Unity has set up some different settings on our camera And in our editor To work well with 2D. Awesome! Now, when starting with an empty project I really recommend visiting the Unity Asset Store to find some assets to use for your game. Of course, if you want you can always replace them with your own custom assets later. Luckily, there are some really great free assets available that we can use. I've gone ahead and compiled a list of some of my favorites. If you want to check them out you can use the link in the description. In here we have a pack for putting together cool pixel art caves They say picks up platformer pack As well as some more toony assets All these are based around tiles And so will fit perfectly with the tile based workflow. If you want to use the sprite based workflow There's also an incredibly detailed art pack As well as a top-down dungeon pack that would work great for that Some of these also include characters But I've gone ahead and added a few separate ones just in case. Now, once you've picked something that you like We have to get it into Unity The way that we do this, it's by opening up the asset store window. So, we'll go window We'll go under "General" and select the "Asset Store". You can also press "Control 9". We'll then navigate to the package that we want to download. I'm just gonna get the free platform game assets. It's right here. So we'll click on that. And once you find the asset, you can simply click this red button to first download And then import it. We'll then get this window Where we can see all of the different assets that are included in the pack And if there's something in particular that you don't want Let's say, you already have a character And don't need this one We can simply uncheck it, But I'd like to import everything. So I'm just gonna a select everything and hit import. This one is called BayatGames And under here we have the free platform game assets And you can see a bunch of different subfolders with the different aspects of our pack And most packs will also come with some kind of a demo scene. In this case, there's a demo folder right here. If we open that up and double click on the scene to open it. We then go into the scene view And we can see this nice example of how you can combine the different elements to create a level. You can, of course, select the 2D Rect Tool at the top here. The shortcut for this is the T key And if you also make sure that you're in 2D mode at the top of our scene view. We can then go in and simply click and change different elements around. We can, of course, move them. Rotate them. And scale them, as well. And so you can quickly start modifying these levels to make them your own. But, of course, we want to create our own custom level. So we'll go back to the default sample scene And we can now start dragging in assets to use them. And how you go about this is going to depend on the pack that you're using. This pack here splits up all the sprites into individual images. So, if we're going to say "Tiles" and then "PNG" We have some different sizes available here. I'm gonna go under 256. I'm gonna select the "grass platform" and drag it in. And that works right away. We have all of our different assets and each one of them is a separate image. So, we can simply drag in some different images to sketch out a level. But what most 2D packs do is that they used a tile set And a tile set is basically just a very large image With a bunch of sprites laid side by side For example, if we go to the asset store and download the sunny land And open up the folder here We can see that on the artwork And then environment In here, we can see that there is indeed a file called tile set And if we have a look at this We can see that it's basically just a bunch of smaller sprites in one larger image. Now, if you want to learn how to create your own tile sets And set them up in Unity. We have a tutorial that I suggest you check out But, luckily, this package has done all that for us. If we just select the tile set sliced here We can see that they've actually gone in and marked all the different tiles that make up this tile set And if we expand this arrow here We can actually see each individual tile in our tile set. Pretty cool! And just like any other image we can take any one of these. And simply drag them in to the editor. Now, this one is a lot smaller, but you can see it works just fine. So, now that we know how to work with sprites. Let's try and build out a quick level here. So, we already have this grass platform here. That's great. I'm just gonna place it here. Let's also add a background. So, I'm gonna go under new background. Under PNG. I'm just gonna select the lowest version here Under background And here we have another file. Let's simply drag that in, as well. And we can see this looks nice in our camera. But we can also see that it's overlaid on top of a grass. And, of course, we want our background to be behind it. For this we use something called sorting layers So, to the right in our inspector here Under the Sprite Renderer We can see the setting called the sorting layer If we click this, we can add a new sorting layer. This takes us to another menu Where we can hit the plus sign to create a new layer Let's call this one "background" And if we want this to be behind the default layer We actually need to put it on top That's because this actually represents the drawing order In other ways, we first draw our background And then we draw the default layer on top Let's just go in and add another one here called the "foreground" In case you want to have some foreground elements as well. So, now we can go into a new background And we can change the sorting layer here to background. And "voilà"! A grass platform appears. We can also maybe add a coin to our game To do that we'll go under the coin animation. Let's go into PNG again And let's just select the small version here And as you can see this has a bunch of different images And if we go through these quickly We can see that they make up an animation. So, to add these as a single animated object. We simply select the first one Hold down shift And select the last one And we then drag all of them in Unity is going to notice that we are dragging in a bunch of images And so it's gonna ask us to create a new animation with these images. I'm gonna make a new folder for this I'm gonna store all of our animation in here. Let's open it up. And let's call this the "coin animation". Let's hit save And inside of our animation folder Unity is now going to create both a animation file As well as an animator controller And this is currently named after one of our images. I'm just gonna rename this to "coin animator". And now if we select our coin We can see that it has an animator component as well If we go to the animation window Which you can always find on the window Animation We can actually go through each individual image in this animation If we hit play We can play through it Or if we simply hit this button to play the game We can see that the animation plays and repeats by default. So, now we have an animated coin in our game We can, of course, move this around Put it anywhere that we would like And just like when creating any game in unity We can then add components to our different game objects in order to make them do different things Say, for example, that we wanted this coin to have physics applied Well, then we could go ahead and add a new component. We can go under physics 2D And here, we have a bunch of different components for adjusting 2D physics on our game object. I'm just gonna select the Box Collider 2D If we then go into the Scene view and select our coin and hit F to focus on it We should be able to seeing that there's actually a green line surrounding our coin. It might not be too visible from the screen recording, but it is there. I'm just gonna give it a size of 1 on the X This way we can kind of see it more clearly And the Y is just fine as it is. But adding a Collider is not enough. If we want this to fall onto our platform We also have to apply physics to it To do this, we'll go add component And we'll search for rigidbody 2D This will apply it physics to our coin And if we now hit play We should see that immediately our coin falls. However, because we don't have a collider on our grass, It's just gonna fall right through on platform So, that's here go and add a box Collider 2D. And we can go in and edit the collider here And I'm just gonna drag the top a bit down So, that it looks like our coin is landing at the center of our platform I'm also going to take the platform and drag it down a bit And if we now hit play once more We can see that the coin falls and lands on a platform We also see that we have this weird issue Where sometimes our coin is behind a platform And sometimes it's in front And that's because they're currently on the same sorting layer And not only that they have the same order within that layer To change that we can go to our coin here And we can increase the order in layer So, if we set this to any value greater than 1 It will be drawn on top of our platform I'm just gonna set it to something like 10 And now when we hit play Our coin always appears on top of our platform. So, that is kind of the very basics of working with 2D objects in Unity, And currently we're just using the default sprite workflow We can take any of these objects and drag it around freely. In other words, we aren't restricted to a grid. However, because this platform actually has a bunch of different tasks in it. It would work great with the tile based workflow. So, let me just give you a quick preview of how that would work. If you want to learn more about using Tile Maps in Unity, We have a tutorial dedicated to that. So definitely check that out. So, for now I'm just gonna take these two objects and remove them And instead I'm gonna right-click in our scene and I'm gonna go to the object And create a new tile map This creates an object in our scene called grid And as you can see this does overlay a grid on top of our scene. I'm gonna set the cell size of this grid to 2 by 2 This way it's a bit larger And under this grid, we have the tile map. We can also go and open up the tile set window So we'll go window 2D And select the Tile Palette Let's dock this to the side of our Scene view And the tile palette is basically just the window where we add all of our tiles And then we can select between them in order to paint them into our scene. So, I'm gonna create a new palette here Let's just name it something like "Grass Platform palette". I'm gonna hit create And I'm just gonna store it in the base folder here So, it's select folder And now we can simply drag sprites in here in order to add them to our palette Of course, we have a bunch of tiles right here So, I'm just gonna select all of them and drag them right in. And it's going to ask us where we want to generate all the tile assets I'm gonna right click and create a new folder for this. Let's call it tiles And it's it that folder It's then gonna generate all of our tiles And voilà! We can now see all of our tiles inside of this window And we can select any one of them by simply clicking on it And by selecting the brush tool at the top here We can then start painting them into a scene. We can also see that they don't quite line up with our grid To change that, we need to select all of our sprites. And to the right here, we'll change the pixels per unit And each of these sprites is 256 by 256 And we want each one of them to be two units wide Because we set our grid to 2 by 2 And so we simply need to take this value and half it And that makes 128. So, we'll set the pixels per unit to 128. And if we then apply that We can see that they snap right into place So I'm just going to use the paint brush and erase the two two a quick level here Awesome! Again, I really suggest you check out our tutorial on tile maps If this is the workflow that you want to use. So, hopefully, that should give you an idea of what tools you have at your disposal When starting to make 2D games in Unity. Of course, this is only the beginning And we'll be releasing new videos on the different aspects of making 2D games going forward Starting with player movement If there are any particular subjects that you would like to see Like enemies, one-way platforms or shooting Definitely let us know in the comments Until then I recommend just playing around with Unity And having some fun sketching out your own levels Also if you like this video and the content in general Consider supporting us on Patreon Patreon allows you to make a monthly donation with an amount of your choosing You can cancel it at any time And it's just a great way to help us keep making these videos On that, thanks for watching! And I will see you in the next video! Thanks of the awesome Patreon supporters who donated in June And especially thanks to... You, guys, rock!