Tuesday, March 31, 2020

Tutorial: How to Make a 2d Platformer in Unity - Tilemap Basics

Setting up the Sprite Sheet:

In the Project window, select ground.png from the pixel2dcastle1.1.zip.  Then, in the inspector change the Texture Type to Sprite (2D and UI), change Sprite Mode to Multiple, change the Pixels Per Unit to 16, and change the Filter Mode to Point.  Next, open the Sprite Editor window, click on Slice, change Type to Grid By Cell Size, change Pixel Size to 16x16, click the Slice button, and before you close the Sprite Editor window click Apply in upper right corner to save the changes.

Creating the Tile Palette:

First, create a folder where you would like to store your Tile Palette and click on Window>2D>Tile Palette.  In the Tile Palette Window, click on Create New Palette and save the palette in the folder you created.  Find the ground.png file in the project view and click the arrow next to it expand the sprite list.  Drag ground_1 and ground_17 into the Tile Palette Window and save the tiles to your folder.  

Creating the Tilemap:

Click on the menu option GameObject>2D Object>Tilemap to create a Tilemap in your scene.  Next, click on the arrow next to the Grid object in the Hierarchy view to expand it and click on the Tilemap object.  Open the Tile Palette window and click on the paint brush icon, select the tile you want to paint with.  Then, paint a row of tiles that we can move the player around on.  Finally, in the Inspector view with the tile map object selected click Add Component and add Tilemap Collider to the Tilemap object.

We're finally ready to start writing code.  In the next part we'll be animating our character implementing running and jumping.

Follow this link to the next post.

No comments:

Post a Comment