Instagram: / kotorman_entertainment
Telegram: https://t.me/kotorman_games
In previous video, we quickly added several wall objects to create simple floor for your character. But it’s a wrong approach in level design. Each object will be drawn separately and create an additional memory load. So, in this case it’s more efficient to use tile palette drawing – you draw each cell with selected sprite and then all cells will be combined into one great static image.
First, we need to install required package. Go to Window, Package Manager and search for 2D Tilemap Editor. In my case, it’s already added to my assets. Then we should create a grid where all tiles will be located. Right click at Hierarchy, 2D Object, Tilemap, Rectangular.
As you see, it generated two objects – tilemap and a grid which holds it. You can create as many tilemaps as you want, combining them into unique layer structures, but in this tutorial we’ll use only one area.
Next, I loaded all the desired sprites into my project. You can change the size of grid cells, I’ll double it to match the size of player. As my sprites have the size of 160 pixels and I want to make them fit the one unit, I set them all 160 pixels per unit.
Now let’s remove the object-based floor from previous tutorial, we don’t need it anymore.
At this moment, we can start drawing our level. To open palette, search for Window, 2D, Tile Palette. It opens the menu where all tiles will be located. Firstly, let’s create palette, I give it a name Default. I’ll add separate folder to store all palettes. Next, drag and drop selected sprites into opened palette. Palette requires to draw tiles that created from sprites, so it asks where to save all generated tiles.
And now you can select every tile and set it into the cells. However, it looks weird, that’s because we doubled grid before, so I also need to double sprites size. Select all images, change Pixels per unit to 80. Great!
By the time I decided to import several background images. To set them behind the scene, change their order inside sprite renderer.
Let’s check our game. Player does not recognize the floor as a solid object because we don’t have any collider. For tilemaps, there is a special component called Tilemap Collider 2D. Now all is good, except jumping mechanics. If you have followed previous tutorial series, you’ll realise that the reason comes from layer system. Script allows you to jump only after collision with ground layer, so change tilemap layer to Ground.
This time character is happy and can jump again, great. Next steps rely on your own imagination, personally I turned scene into this…
In future tutorials we are going to consider camera following using ready solutions and packages. So subscribe to our channel, play our games, thanks for watching!
#kotorman #gamedev #unity #firstgame
Смотрите видео UNITY FIRST GAME | PLATFORMER 2D (EASY) | Tilemaps онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Kotorman Entertainment 25 Февраль 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 166 раз и оно понравилось 3 людям.