Now what we will do.
We will disable this enemy too, and this white ground for.
And we're just gonna place our tiles to do that.
Let's select this ground and this player by holding down Ctrl or sorry, uh, by let's select this ground
and this enemy too, by holding down Ctrl on your keyboard.
Then go over to Inspector and then uncheck.
Basically you just disabling that.
And now we're going to create our grid.
But before we do what we want to do we basically gonna create a tile map folder.
And into that folder we're going to drag our tiles that we just going to put it in our tile palette.
To do that we need to head over to this project tab then asset right click on it then create folder.
And we're going to call this folder to something like Tile Map.
So we created this folder in order to keep our project clean.
And we will place the tiles over here.
So that's why.
And now what we have to do we basically need to find our tile set?
So for that I will move over to my project tab assets and then sprites folder.
Then I will head over to my environment folder, then tiles folder.
Of course I will have this in the resources.
You can go and check that out.
So we're going to select I'm going to select this both of these tile set sprite sheet.
Then go over to Inspector and Sprite mode to.
We're gonna choose multiple.
Why?
Because we want to.
We just want to slice these tiles individually by 16 by 16.
So that's why.
And also we're going to make this pixel per unit 16 since we just want to slice individually 16 by 16.
So we're going to choose 16 and filter mode to point of filter because this is an pixel R.
Or you can simply say to get rid of blurry, we need to choose this filter mode to point no filter.
And after doing all of these things, click on this apply button in the bottom right.
And now it's done.
And we need to create our grid before we place our tiles.
To do that, move over to your hierarchy.
Right click or hit this plus icon.
Then go over to 2D Object Tile map and then rectangular.
And we can call uh we don't need to name it.
So we have the tile map underneath our grid game object.
I'm going to select my create.
Let's drag it into top of my hierarchy so I can see all the time.
And if we select our tile map and move over to the scene view in the in the top left side I can see
Tile Palette tab tile.
So we can just click over there in order to open that up.
And if you are not able to find your Open Tile Palette tab, you need to find it in the scene view you
can get anywhere something like in the bottom right, bottom left or top right or top, uh, left or
middle center anywhere.
So you need to find that.
And after finding that make sure you just click on this Open Tile palette.
As you can see it says drag Tile Sprite texture sprite assets create a new tile palette.
So firstly we need to create a tile palette.
So to create that let's click on this Create New Tile palette and then click on this Create New Tile
palette.
And we have to name the palette what we want to want to name it.
So I'm going to call it Tile palette.
Something like that.
Uh, I really apologize if I am misspelling this.
I guess it should be tile sorry tile palette okay.
Tile palette.
And let's click on this create button.
And now we need it's going to take us to a folder where we want to place it.
So we will go to top left assets.
And as you can see inside assets we created a folder called Tile Map.
As you can notice in the bottom.
So we're going to choose that folder.
And let's click on this select folder in the bottom right we can see.
And now we are ready to drag the sprite sheet right over here.
Uh, so now what we're going to do, uh, firstly we will choose our, uh, this sprite sheet.
Let's click on this open sprite editor.
Uh, so we need what we need to do.
We need to slice individually.
So make sure you select your sprite sheet which is the tile sprite tile set.
Then click on this.
For now I'm going to get rid of that.
So then go over to Inspector.
Click on Open Sprite Editor.
Then go over to your Sprite Editor tab.
Then click on this slice button in the top left you can see uh.
So just click there and select Automatic to Grid by cell size.
Uh make sure you just do that.
And in the pixel size we're going to choose 16 by 16.
In the X we're going to do 16.
And in the Y we're going to do 16.
And in the bottom we can see slice.
So just click on that slice and then click on this apply button and do the same thing with this uh with
this with this tile set sprite sheet.
--.
So let's click on it.
Let's click on Sprite editor.
Let's select automatic to create pixel size slice and then apply.
And now it's done.
And now what we can do I'm going to select my game view once again.
And let's go over to hierarchy.
Then Create Game Object.
And let's select this tile map.
As soon as we select we get a pop up or the tap in our scene view Assess Open Tile palette.
So let's click on it and we are ready to drag the sprites right over here.
Individual styles.
But instead of dragging that.
So if I move over to my tiles folder and then click on this arrow inside the basically into this tile
tile, set sprite sheet and then click on this arrow.
We can see the individual.
So instead of selecting individual we just want to select the whole sprite and then drag it over to
this tile palette tile palette in your Tile Palette tab.
And it's going to take us, take us to a folder where we want to place it.
So we will go to assets in the top we can see or you can see in the top left side.
Then we're going to choose our tile map folder and let's click on this select folder.
As soon as we're going to select Folder Tile just going to be over here in our tile palette as you can
notice indeed.
And let's do the same thing with this tile sets.
So let's select that and drag it over to this in view sorry.
Drag it over to this Tile Palette tab.
And now it's going to take us folder.
So let's go to Assets Tile Map and let's click on this select folder.
I really apologize for this.
And now this seems pretty much cool.
And we are ready to place our tiles.
And in order to place your tiles in the top bar you can see many tool.
So we have the brush tool.
And to paste our tile and the shortcut key we can notice is B.
So we can select this tile.
And we can just paste it in the scene view right away, and we can select this tile like this.
And we can just paste it.
And let's suppose you just place the wrong tile.
Let's suppose I just place, uh, this this should be the end.
So what we need to do, we need to select this tile which is top left.
We can see in our tile palette tile palette.
We just want to place it.
So we're going to do that.
And if we just place it over here as you can notice it's uh mistakenly we have done.
And let's suppose you just want to erase that.
To do that, you need to select this eraser tool in the top bar.
You can see in your Tile palette tab.
And the shortcut key is T.
So if you simply press down T on your keyboard, it's gonna take you to that, uh, tool.
And we can just erase that tool or, or we can simply erase this whole by selecting like, this in our
tile palette and then choosing this brush, sorry, erase tool.
And we can just erase at one time this whole thing, as you can see.
And if you've done any mistake, then you can just press down Ctrl Z on your keyboard in order to undo
anything that you want to do.
So I want it back so I can simply press down Ctrl Z on my keyboard in order to get it back, as you
can notice.
And I'm gonna place my tiles.
So let's choose this brush tool and let's select this.
Or we can simply select this whole thing like this.
And we can just paste it in this in view directly like this.
So I hope you get the idea.
And I'm gonna, uh, I'm gonna do with this one and let's do it here and let's paste it.
And this seems pretty much cool as you can notice.
So this is way much cool.
And we can just place and for in the top right corner we're going to do this.
And let's select this.
Let's paste it over here then this this, like that, and now this is fine.
And I'm going to cut this tile palette tab for now.
And the problem is that, uh, but before we do, let's call this tile map to something like ground
tiles.
Since this, uh, since we're gonna have multiple tile sets, like, for grasses, uh, back tiles or
all of those things like that.
So that's why we need to specify this.
Uh, this will be our ground tile.
So let's rename that as ground tile.
That tile map.
So let's go over to hierarchy.
Let's go over to Grid Game Object.
Underneath our grid we can see Tile map.
So let's do that and let's rename it to something like ground tiles.
So let's rename this to Ground tiles ground Tiles.
And make sure you just make this grid game object a prefab.
So you will have the copy.
And you don't need to work from scratch or you don't need to start over.
So we're gonna select this grid game object in the hierarchy, and let's drag it over to this prefabs
folder in order to turn it into a prefab.
Uh, into a prefab.
Sorry.
Uh, create I have this one, so I'm going to select this one.
Let's delete that.
And let's go back.
And now this is fine.
So make sure you just make it prefab.
So you're gonna have the copy of it.
And the problem is that if I just go ahead and then click on this play button in the top, you will
notice this player game object just passes through this tile ground tiles.
Why?
Because we haven't added any collider to these tiles or individual tiles.
So that's why our player GameObject not gonna detect any collision.
So that's why it's gonna just pass through this ground tiles.
And you will see as soon as our game just gonna start.
And indeed we can see it just passes through this ground tiles.
So what we need to do, we need to add colliders to this individual tiles or this ground tiles.
So let's get out of play mode and let's select the ground tiles underneath our grid GameObject in the
hierarchy.
Then go over to Inspector.
Then click on this add component in the bottom and you need to add Tile Map Collider so you can simply
type.
Basically, you can find the component by typing name of the component, which is tile map Collider
or what else you can do.
You can click on this add component.
So add component.
Then you need to move over to this physics 2D.
And you need to find the Tile Map Collider over here.
You can find it here.
So we can notice rigidbody.
We have multiples.
But instead of doing that simply search over here.
Uh like this tile map collider.
And it's going to pop up.
And let's click on this tile Map Collider.
And as soon as we just added our Tilemap collider, we can see the collider just added up to our individual
tiles.
And now if I just go ahead and then click on this play button in the top, you will see this player
game object will not able to jump on top of this tile map.
Basically it's just gonna stand.
And for the first time it's gonna jump.
But for the second time, it's not gonna do at all.
Let me show you why.
So if I just jump and as you can notice, we can move left and right and we can jump.
But the problem is that if we jump by now, we can see our player just stuck at jump animation clip.
So if I select my player in the hierarchy, then go over to my animator tab.
As you can notice our player stack at player jump.
Uh player jump animation clip y.
And we also not able to jump anymore because we just jumped on Tilemap Collider, which is not our ground.
So what we need to do, we need to get out of play mode and we need to assign this Tilemap Collider,
this collider as a ground tag.
So this player GameObject will know that this is our ground and it's gonna jump atop.
It's gonna jump.
So we need to assign this ground tiles as a ground attack as well as ground layer.
So this player GameObject will know this is our ground ground tiles or this is our ground simply.
So we're going to choose our ground tiles.
Let's choose that.
Go over to Inspector and Tag.
As you can notice it says untag.
So let's assign with our ground tag.
So now this is our ground and layer.
We're gonna choose our ground layer.
So let's assign with ground.
So now by now this player objects are just gonna know that this is our ground.
And if I go ahead and then click on this play button in the top in order to play our game, you will
notice that this player game object just gonna just gonna jump are able to jump from from top of this
ground tile game game object from from this ground tiles.
So let's have a look.
So if I jump as you can see indeed indeed we can see that we are able to jump for the next time as well.
But let's suppose you just want to merge all of these individual collider at once.
So how you can do for that get out of play mode?
For it you need to add a component.
It's called Composite Collider 2D.
So make sure you select your ground tiles.
Then go over to Inspector.
Click on Add Component and you need to find it over here by Crown it.
To sound common, you need to find composite Composite Collider 2D and then attach that and then go
over to Rigidbody 2D and set the body type to kinematic.
and collision detection to continuous, and you can choose interpolate to interpolate to making a little
bit smooth.
And after doing that, what you need to do, you need to move over to this Tilemap Collider and then
over here composite operation.
As you can notice it says none.
So you need to click on it and then click on this match.
And as soon as we click on it merge, we can see individual colliders just compiles at once, as you
can notice.
And make sure you just go to your parent game object.
Select the parent, then go over to Inspector, then overrides and then apply all.
So the changes you made inside this grid game object it's going to be saved.
So let's suppose you want to move this ground tiles at somewhere something like over here.
So how you can do that for it.
Go over to hierarchy, then create then ground tiles and then click on this open tile in this scene
view.
And you can select this tool.
And the tool is called a area of the grid.
And the shortcut key is ace.
So we can select that and we can select the tiles or which tile we just want to move.
Since I want to move this all up is somewhere over here, then we can just select this and we can click
on this this tool next to it.
And it's called a selection tool.
And the shortcut key we can notice is M.
So we can select that.
And now we can select our round tiles.
And we can just move it anywhere we like.
As you can notice in this end view like that.
And let's suppose you just want to make a copy of this round.
Then you can just select this tool.
And this tool called is Pick or mask tool.
And the shortcut key we can notice is I.
And we can just select this round tiles.
And we can just make a copy as you can notice.
And we can just paste it in in our scene view anywhere we want something like that.
As you can notice, and if you want to erase this, uh, this ground tiles totally, then you can just
select like this in your tile palette like this bigger.
And then choose this eraser tool in the top bar.
You can see in your tile palette tool.
And then you can just erase at one time.
As you can see, as soon as we just click, uh, that whole tile just get disappear or we just erase
and let's suppose you just want it back.
Uh, then you can simply press down Ctrl Z on your keyboard in order to undo, as you can show, as
sorry.
As you can see, as soon as we have done it, we can see we just get it back.
Our, uh, this ground tile, and I want to have it a back tile.
So for that we need to create a new tiles.
To do that, firstly you need to move over to hierarchy.
Then go over to this create Game object in your hierarchy tab.
Then right click on this Create Game object.
Then go over to 2D object, then tile map, and then click on this rectangular and you can call this
one something like tiles.
So since this is going to be a tile so I'm going to call it something like back tiles.
And if you have grass then you can just call it something like grass tiles something like that.
So what I'm going to do I'm going to name this to something like uh back tiles.
So, so let's call it uh, back tiles, sorry, back tiles.
And what we're going to do now, we're going to choose our back tiles, then go over to Scene View and
then click on this open tile palette.
And now we're going to choose this, uh, dark dark dark dark tiles like this.
It should be behind or basically these tiles and it should be behind our ground tiles.
Uh, so uh, so I'm going to paste it somewhere over here, as you can see.
But the problem is that it seems in front of our ground tiles and we want it back.
So what we need to do for it.
We need to assign some sorting layer for this ground tiles as well as back tiles for that.
I'm gonna cut this tap Tile palette tab for now.
And let's select this tiles or this ground tiles.
Then go over to Inspector, then Tilemap tile map renderer, then additional setting sorting layer.
Click on it and then click on Add Sorting Layer and create two sorting layer by clicking on this plus
icon.
And you can name the name it something like Ground Tiles and you need to create one for your back tiles.
As you can notice, I already created.
So I'm gonna click on this minus and I just drag it this ground tile in front of this tiles.
And if I just drag this back tiles in front of this ground tiles, then this tile is just gonna be in
front of our ground tiles.
Since I want this back tiles to be behind of my ground tiles.
So that's why I'm going to choose my back tiles.
And I'm going to drag it behind my ground tiles.
And we need to assign our back tiles with these back tiles sorting layer.
And we need to assign this ground tiles as a ground tile sorting layer.
To do that let's go over to hierarchy, then create and then let's choose this ground tiles.
Let's go over to Inspector, then tile map renderer, additional sorting settings then sorting layer.
And we're going to choose our ground tiles.
And for this tiles.
So let's choose our back tiles.
Then go over to Inspector Tile Map Renderer and Sorting Layer.
We're gonna choose for this tiles.
And as soon as we have clicked clicked on it we can see by now our tiles is behind of our ground tiles
as you can notice.
So I hope you get the idea that how you can do it.
And we have many tools in our Open Tile Palette tab.
We can see we can flip our tiles, we can just rotate our tiles as well as we can just flip our tiles
vertically.
So I hope you get the idea that how you can do it, and you can just get it and make sure you always
go to parent game object.
If you turn it your game object into a prefab, then make sure you select the parent one.
Then go over to Inspector Overrides and then apply all.
So the changes we made, it's just gonna save.
And I'm not gonna I'm not gonna attach any colliders to this back tiles since we don't want to collide,
and it should be behind of our player.
And if we go ahead and then click on this play button, it's gonna work fine.
And we only added the tile map collider to this ground tiles.
Not with this tiles.
And if you have a grass, then you can create a new tile map for your grass.
And you can just do it as I have done.
You can just follow the same process, So I hope you get the idea that how you can do it and you can
just go ahead and you can do that, and if you a little bit confused, then don't worry, I'm gonna
have a video in the resources.
You can go and check that out if you just want to learn more about tiles.
And if I play around, as you can notice, this seems pretty much fine and we can jump and we need to
make our jump a little bit small instead of making too much high.
And we can notice we can attack the.
And this seems pretty much cool as you can notice.
So I hope you get the idea.
And if you have something like four objects, then you can create a new tile map for your objects and
you need to assign with sorting layer some sorting layer so you can have it perfectly.
So I'm gonna get out of play mode, and I will press down Ctrl s on my keyboard in order to save my
project.
So I hope you get the idea that how you can do it.