Unity 2D Bomberman Game Tutorial
In this Tutorial we will make a clone of one of the most fun games of all time - Bomberman. We will only write about 80 lines of code and everything will be explained as easy as possible so everyone can understand it.
Our 2D Bomberman game will be inspired by the original Bomberman from 1983. What sounds like a really old game, is still a phenomenal example of fun gameplay.
We will use several interesting Unity features such as Rigidbodies, Colliders and the Sprite Editor. We will also learn how to properly use Unity's incredibly powerful Mecanim Animation System.
While this Tutorial will be explained as easy as possible, a basic overview about Unity (especially the 2D features) is a good thing to bring with you. If you are completely new to Unity then feel free to read through our easier Unity Tutorials like Unity 2D Pong Game first.
If you already know where to find the Hierarchy, how to use the Inspector and what a Transform is then there isn't anything to be scared of. As usual we only use the techniques that are completely easy to understand, without any scary math.
Our Bomberman Tutorial will use Unity 5.0.1f1. Newer versions should work fine as well, older versions may or may not work. The free version of Unity 5 now comes with all the engine features, which makes it the recommended version.
Creating the Project
Let's get to it. We will start Unity and select New Project:
We will name it bomberman, select any location like C:\, select 2D and click Create Project:
The Background Color
Afterwards we select the Main Camera in the Hierarchy, look at the Inspector and change the Background color. The original Bomberman game uses the green background color #397c00 (R=57, G=124, B=0). We can use that color, or any other color that we like. We will also adjust the Size property so that the game looks big enough later on:
Creating the Level
The Undestroyable Block
We will have several types of blocks in our game. At first, we will need one block that can't be destroyed. We will create a 32 x 32 px texture with a tool like Paint.NET:
Note: right click on the image, select Save As..., navigate to the project's Assets folder and save it in a new Sprites folder.
Alright, let's select it in our Project Area:
And then take a look at the Inspector, where we can modify the Block's Import Settings:
Note: a Pixels Per Unit value of 32 means that 32 x 32 pixels will fit into one unit in the game world. We will use this value for all our textures, because Bomberman will be 32 x 32 px later on, and we want him to be exactly one unit in the game world.
Afterwards we can drag the block image from the Project Area into the Hierarchy:
Now we can even see it in the game if we press Play:
Right now the Block is just a image in the game world, a purely visual effect and nothing more. We want it to be part of the physics world, so that Bomberman can't walk through it. We can make it part of the physics world by selecting Add Component->Physics 2D->Box Collider 2D in the Inspector:
Now the Block is part of the physics world, just like a wall.
There is one more thing to do here. We will have two types of blocks in our game: destroyable and undestroyable blocks. We need a way to find out if a certain block is destroyable or not. There are a lot of ways to do this, like writing a Script or using a Tag. We will keep things simple and use the Static property for things that are not destroyable:
Note: we usually use the Static property to tell Unity that certain GameObjects will never change. This way Unity can do optimizations with them. And since our undestroyable block will never change, making it static is just the way to go.
The Destroyable Block
Alright so let's add another block to our game. Like before, we will begin by drawing one:
Note: right click on the image, select Save As... and save it in the project's Assets/Sprites folder.
We will use the following Import Settings for it:
Afterwards we will drag it into the Hierarchy again and then select Add Component->Physics 2D->Box Collider 2D in the Inspector:
Using the Blocks to create a Level
Now we can use our two blocks to create a simple level. We can duplicate a block by right clicking it in the Hierarchy and then selecting Duplicate:
We can duplicate the blocks as often as we want and position them to create a simple level. We just have to remember to position each block at rounded coordinates like (1, 2) instead of something like (1.002, 1.9998).
Here is what a full level can look like:
Note: we also grouped all the Blocks into an empty blocks GameObject which we can create in the top menu at GameObject->Create Empty. But this is optional, as it's just to keep our Hierarchy a bit more clean.
The Bomberman Character
Alright, let's create our Bomberman character. Our character will be able to stand idle, move to the left, to the right, up and down. We will need 5 animations to make this possible. Sounds like it will be a lot of work, but as usual Unity takes care of all the complicated stuff for us.. . .
Premium TutorialEnjoyed this preview? Become a Premium member and access the full Unity 2D Bomberman Game Tutorial!
All Tutorials. All Source Codes & Project Files. One time Payment.
Get Premium today!