Hello guys.
Welcome to the video.
In this one I want to show you how to set up a level with the tile set and how to use tile set and tile
palette to, you know, make levels.
It's not that difficult.
We just need to do a couple of steps to make it ready, and then you can just draw the level like you
would use a brush or something like that.
So first of all, let's delete these platforms.
We're not going to need them anymore.
So we're going to delete it.
And let's go to window 2D tile palette.
Now we have a tile palette window.
We need to drag it to the hierarchy over here.
Just like that.
Then in the title palette we need to click Create New Tile palette.
We're going to have just one tile palette, so that's why I'm going to name it as tile.
And let's click create.
Now this system tells can create lots of files.
And if you don't take control of them, it can be very messy in the project window in the asset folder.
That's why I'm going to ask you to do everything as I do so we can keep it clean.
You're going to make a folder over here.
I'm going to call it Tile Palette.
Let's open this folder and let's select it.
Now over here we're going to have tile palette created.
After that we need to fill up tile palette with the tiles so we can use them.
Let's go to Graphics Terrain.
And over here we have two files.
One of them is just like that and another one is sliced.
I think they are actually the same.
So we don't need this one.
That is terrain with the number one.
Let's delete it.
And let's take this terrain sliced.
Let's make sure it is sliced.
Yes it is.
Okay.
This is good for us.
Now let's choose pixel per unit 16 and hit apply.
After that, we can just open this window.
Something like that.
And we can take the entire sprite sheet over here and just drag it to the tile palette.
Now here it is very important.
Go to assets.
Oh yeah.
Tile palette.
Create a folder.
Let's call it assets.
Assets.
And then we're going to click asset and select folder because this one will create.
Let me show you tile palette assets.
It will create a bunch of files that are used in the tile palette.
And it's better to keep them in one folder because we're not going to use them, but they make a real
mess if you put them just somewhere.
Okay.
Nice.
So now we have a tile palette and it's time to use it to draw level, to draw the level with the tiles
you've made, you actually need to make a grid that can be used to draw.
Let's click right button to d l map rectangular.
And we've created a grid.
This one's going to be used for ground and platforms, so let's just call it ground.
Very nice.
Now we can go to the tile palette.
And over here we have a bunch of tools.
I'm not going to explain them much because if you put your mouse over them you can see what they do.
This one moves selection with active brush.
This one paints with a brush.
This one paints with a field box.
This one is a picker.
So you can just, you know, try them out.
You can take them and use them and see what they do.
The only thing I want you to know is that.
You can go to edit mode over here, and these tools will work in the edit mode as well.
So you can adjust style palette here, but make sure you exit to the edit mode when you're done, because
otherwise you can mess up your tile palette over here.
So I'm going to select edit mode.
I'm going to erase this over here.
And I'm going to exit the edit mode.
Now we can select one of the tiles for example this one and draw it somewhere here.
Then we can select another one.
Draw the platform.
Then we can select the corner together with maybe these draw a platform like so.
Now we need to fill up the bottom part.
We can just select these two.
Drag it like oh I'm sorry drag it like so and then select the corner and drag it like so.
Also you can use the fill up box which is also very useful.
You can select this fill up box.
Then select some tile and just drag it to make anything like that okay.
Yes.
Uh.
Something important.
If you hold shift key on a keyboard, you can erase tiles.
If you want.
Okay.
Now we're not going to draw much for now.
We just want to understand how the tile palette works.
And then we're going to move to the next video.
So as you can see we have the tile palette.
We can use tools to draw the levels.
But now we have a problem.
First of all, let's fix the problem we have.
If I go to the play mode.
My character is going to fall through the platform.
Not cool.
And that is happening because we don't have a collider on the ground.
If you remember, colliders are very important.
We need to add a Tilemap collider.
Now we can go to play mode and player will stand on the ground.
As you can see, we have a bug.
Now he thinks he's in the air.
So let's select this ground.
Go to layer and choose ground.
Okay.
Let's try again.
And we can see we are on the platform and it's working very well, although we need to do one thing
to improve it.
As of now, you can see it has sort of a bunch of colliders, as many tiles we have as many colliders
there are.
And every time we do in collision check, we do check against each collider there, which is not very
cool.
So we need to combine them into one collider to improve performance for the.
So we're going to go to the add component and we're going to type Composite Collider.
This composite collider will unite everything before we go to the Composite Collider and use it.
Let me explain the body type of the rigid body because now it is important, as you remember, on the
player over here, we had body type dynamic and dynamic.
Rigid body means that this rigid body can move and it is affected by the physics engine.
Gravity is applied to this rigid body and other physics.
You know interactions can be applied to this rigid body.
Kinematic says that object can move.
You can move the object maybe with a script or something like that.
But the physics are not applied to the kinematic rigid body, so it will not be affected by gravity,
for example.
And static means that rigid body cannot be moved at all.
And this is what we need for the ground rigid body over here.
So we're going to turn it into a static.
Now it cannot be moved at any, you know, circumstances.
It will be there.
And because of that it will allow us to basically use this rigid body for the platforms and ground because
that one not supposed to be moving.
Yeah.
Let's.
Let's cover this up here.
And now we need to go to the Tilemap Collider and choose Composite Operator Merge.
And now this one was merged into one collider which is very, very useful and very, very nice.
Yeah.
Um, there are some things like maybe you should know about, uh, geometry type.
So this one basically does the outline and polygons will divide your platforms into polygons.
As of now we just have a simple platform.
So it does not do that.
But if we take something and draw it over here, you can see it was sort of cut into polygons.
And it is usually used if you have some, you know, slopes, some uneven ground where it goes up and
down or anything like that, but we're going to have only square and rectangular platforms because of
that.
We're not going to need the polygon geometry type.
We're going to keep outlines.
This will be better for the performance.
Now um, I'm going to hold shift and select this to remove it.
And I need to go back and fix this area over here.
Let's just do it like so.
Okay.
I'm asking you not to rush and not to create level yet.
Let me explain everything.
And also in the next video I'm going to show you how to make a rule tile, which makes it a bit faster.
And then you can create a level.
Okay.
So uh, we have a platform, we can walk on the platform, but now we don't have anything else on the
level.
And I think it's a good idea to have a background on the level.
To make a background, we need to make another 2D, uh, tile map.
Rectangular.
Let's call it background.
Let's go to the tile palette.
And over here now it is very important.
What do you choose here?
If you choose ground you're going to draw on the ground layer.
Basically, if you choose a background you're going to draw on a background.
The difference between them is very simple.
One has collider, another one does not have a collider.
So we can select background, find background images.
Oh they are not here.
Where are they.
Graphics background here are backgrounds.
Let's select them all.
Do a pixel per unit 16.
Uh sprite mode multiple and hit apply.
And for now I'm going to use only one of them because we don't really need to spend time on the entire
decoration.
So I'm going to take maybe this yellow and I'm going to drag it.
Or actually we need to cut it first.
Let's open sprite editor do slice grid by cell size.
I'm going to do 16 by 16 and slice okay.
Uh yeah.
Save it.
Now we can drag it here.
And we need to go to Tile Pallet Assets select folder and we've got the background tiles.
Later on I'm going to show you how to make animated background, but it's going to be later.
Now it's not that important.
So let's use this background.
We're going to choose it choose background.
Then we can go here and draw background.
Now there is a neat trick that we could use.
Let's select it with a color picker.
Oh, yes.
And now we can draw it.
Okay.
Just like that.
And over here you may see a problem.
Now we cannot see the platform.
It is behind the background, which is not correct.
Right?
We need to fix it.
We can fix it with the help of a sorting layer.
Over here in the Tilemap renderer we have sorting layer and this will define what is drawn behind what.
Let's go to certain layer and click Add Certain Layer.
Over here we're going to click plus.
And you should know that the lower the position is the higher priority it has.
So we should have background then we need.
Ground, then we need player and player should be below everything because player has the most, uh,
like the highest priority right now.
Let's go to the ground over here and choose certain player ground to the back ground.
We're going to choose background.
And for the player on the animator we're going to choose player just like that.
Now the ground is behind the platforms and player is in front of everything.
Very cool.
And we basically have a like almost a level to play with.
Uh, we're not done yet.
While we are on this certain layers, let's add a couple of more that we're going to use in the future.
We're going to add another layer and it's going to be behind the player.
Then we need items and I think it can be behind the player but in front of the enemies for now.
Later on we might need to fix it.
This is going to be pick up items like fruits and everything, and let's add traps and let's place them
behind the enemies.
Okay, so these are certain layers that we might need later.
There is also a order in layer for the sorting layer.
And just to explain what it does.
Um.
We actually we don't need to use it now, so there is no point of explaining it.
I'll just say that the higher order is the more priority it has.
So you can have objects within the same layer.
And let's say you need to place one in front of another.
Then you can use order and layer.
So let's say you have decorations and you want one decor to be in front of another one.
So for that one you would make order in layer 1 or 2.
Okay but no worries we're going to use it later on.
I'm going to show you how it works for sure.
So I just don't worry about it okay.
So now we have background and ground.
We know how to draw platforms.
But again don't be in rush.
Don't create level yet because I'm going to show you how to make a rule tile which makes process faster.
Yeah I'll see you in the next video.