Gaming Art - Week 7 | Tilemaps in Unity
Today's class was pretty cool, even though it was a 2D technique: how to create tilemaps in Unity. And it really is easy, I was impressed. So the first thing to do is create the tiles in Photoshop. It is important to show the grid and rulers and to have the units in Pixels, so that we know exactly how big the squares and tiles are. Also it is better if we do not leave an offset between tiles and border of canvas because then we have to specify the offset in the Sprite Editor (which is not difficult but you can spare time).
Then in the Sprite Editor instead of Automatic select Slice > Grid by Cell Size. We knew that the Pixel Size was (144px) and the offset was 72px.
Then apply.
Create > 2D Obejct > Tilemap. It will be under the created Grid.
Open Window > Tile Palette. Now we can create palettes with different tiles to paint with. Create New Palette > save it in a new Folder "Palettes". Then select the tiles you need for that palette, like all the dirt ones, and drag and drop them in the tile palette window. Save them in the Palettes folder. Repeat with every type of tile.
Now with the brush and a tile selected you can paint the tiles very easily.
Create a new Tilemap (different layers would make a difference) for every layer of tiles. Then assign different Orders in Layer to make some be behind others.
Then create a Sprite (Create > 2D Object > Sprite) and add a circle as the source. Add a 2D Rigidbody and a Circle Collider so that the circle collides with the ground.
Then add a C# Script to the circle to make it move and jump. I do not know why but I could not attach the camera to the circle so that it moves with it, it would just rotate crazy so I left it like that.
Then in the Sprite Editor instead of Automatic select Slice > Grid by Cell Size. We knew that the Pixel Size was (144px) and the offset was 72px.
Then apply.
Create > 2D Obejct > Tilemap. It will be under the created Grid.
Open Window > Tile Palette. Now we can create palettes with different tiles to paint with. Create New Palette > save it in a new Folder "Palettes". Then select the tiles you need for that palette, like all the dirt ones, and drag and drop them in the tile palette window. Save them in the Palettes folder. Repeat with every type of tile.
Now with the brush and a tile selected you can paint the tiles very easily.
Create a new Tilemap (different layers would make a difference) for every layer of tiles. Then assign different Orders in Layer to make some be behind others.
Add a 2D Collider under Component > Tilemap > Tilemap Collider 2D to the dirt layer, so that the character can walk on it. It will automatically create the colliders.
Then create a Sprite (Create > 2D Object > Sprite) and add a circle as the source. Add a 2D Rigidbody and a Circle Collider so that the circle collides with the ground.
Then add a C# Script to the circle to make it move and jump. I do not know why but I could not attach the camera to the circle so that it moves with it, it would just rotate crazy so I left it like that.
Comments
Post a Comment