Hey, welcome back, my fellow game developers.
So as you can see what I've promised you
that we are going to make it a little bit better.
I've delivered on my promise.
Now when we run the game,
you'll notice that there are no blue spots, no blue lines.
And if I walked through,
I tried to walk through this.
It's a wall. If I walk up, It's a wall.
Obviously, we have a couple of things that we can change.
If you look closely in Scene mode,
obviously, it's not perfect yet,
but you can see when I shoot a wall,
it is a wall from the back,
from the front, and the enemy still chases us.
Everything is good, everything works fine.
So let's not waste any more time and let's get started.
Oh, case.
So now that we have set up everything time to use it in a proper way.
So the first thing that we need to understand is
the tile map and what the inspector of that tile map does.
So we've created the walls, the ground,
and you can see that they also have,
each one of them has a tile map component and a tile map renderer.
Because the tile map renderer works just like the sprite renderer,
we can also choose a layer.
So for example, I can go to the ground and choose the layer background,
the walls, the layer background.
And I can make, for example,
the walls one and the Ground Zero.
You can play around if you want.
You can even create your own sorting layer depending on
how many things you want to be in the foreground or background.
So I'm going to, first of all,
delete everything or erase everything, should I say?
So I erase everything and you can see why is this not getting erased.
So let me just make the screen bigger.
Why is this not getting a raise?
Well, because we are using where is it?
The active tile map is the ground.
So we can only delete things that are on the ground.
If I choose the walls.
There you go. I can now delete it because when I created this, I used walls.
So let's just do a little test.
Now that we have the sorting layers setup,
I'm going to create this big square right here,
which is, oops, not the ground,
excuse me, the ground.
And now I'm going to create this little ground right here.
And now if I go into the walls and let's go ahead and add this one.
So you remember why did we have the blue lines before?
Because we had these outlines right here.
You can see that they are transparent,
so they only reflect what was behind.
So now because these are,
let me click on this one.
So now because this is the walls and the walls are rendered in front of the background.
When I put them here, there you go,
you can see that there are no longer
any blue lines behind which represent the color of the background of the camera.
I can also do this right here.
So I'm going to select them.
And you can see because they are walls,
I can immediately draw on top of them.
But you can see right now to inconsistency,
how do I, for example,
drought is to have a continuous third wall and fourth wall.
Well, in that case,
we'll need to select something different,
which is these lines right here.
And now we can add the illusion or create the illusion that we have.
Let me just create the illusion that we have these all connected together.
And if you look in the game,
if I run the game,
Also, it doesn't matter.
Let me just make this game window bigger. There you go.
You can see how all of that looks at,
looks as if we have everything normally
setup and we can just run the game and walk around.
And then you go, you can see that I can walk around on top of this.
Everything works perfectly fine.
But the problem is that now I can walk through
the walls and this is usually not a huge problem,
but having your player leave forever plus,
plus when we are shooting,
you can see that the bullets will keep on going
forever because they are not interacting with anything.
Or we don't have any more walls,
they are not interacting with the walls.
So how are we going to fix this?
Well, we can go ahead and start adding colliders and all of that good stuff.
But obviously this is not the most efficient solution of solving the problem.
What we can do, on the other hand,
add something called a tile map collider.
So if I go onto the walls,
and that is why we've created walls,
not just the ground.
Go to the Inspector.
I can add a component in here which is going to be
the tile map collider 2D. And there you go.
You can see that now everything under the walls has the green collider on him.
And you can see that they are intersecting.
Why? Because we made them just a little bit
bigger than where's the picture? There you go.
We made them just a little bit bigger than 16. We made them 15.
If I make them 16, I think we can start seeing cracks in between each sprite.
Now you know what? It looks good enough.
I think there is no discrepancy in.
Okay, so let's keep it at 16.
So I changed the pixels per unit to 16.
And now if I choose the walls,
there is still an intersection,
but that's okay, that's not a huge problem.
Let me just demonstrate that this works.
So now if I run,
you can see that I hit a wall and I cannot go through it anymore.
Excellent, everything is working.
They are on the default layer.
You can change the layer if you want also of each tile map.
But now there is something that we need to add this,
adding this glider is not enough.
What we do is we need to add something called a composite glider.
Why? Let me show you how that will change everything and you'll understand by yourself.
So now that I've added a composite Collider,
you'll notice that I also added a automatically a rigid body.
So a rigid body is required when you have a composite collider.
And if you look right here in the tile map collider,
you can see that we have something called used by compass.
If I turn this on, there you go.
You see that we no longer have a lot of gliders.
That means just do that again,
uncheck the US by composite will notice that we have a lot of colliders.
When I do use the composite,
we only have one collider on all the shapes.
This is extremely helpful.
I cannot emphasize the fact how much this saves
energy and computational power from our compute.
This will allow us to create a single collider around a lot of entangled gliders.
So make sure that you add a composite collider 2D with that.
Understood.
Now, it's time for a small challenge.
Or before we do that,
I just want to run the game to maybe make you understand what the challenges.
If I run the game.
And there you go,
you can see that something is definitely seriously make this part of your game some,
at some kinds of mechanics of the game.
So the player plays around with the game and with the map.
So hey, the, let me just zoom out a bit so you can see that
the map isn't behaving completely how it should be.
I think that's an understatement.
Let me just try to push that off and there you go.
So now we no longer have a map and it keeps falling so well that understood.
Out of the way, that thing we'd think I'm not fix the problem was the following map.
If you don't want any hints,
you know how to fix this.
Pause the video right now, go to the challenge.
If not, check in the inspector on the tile map,
you'll see a rigid body.
This means that we have a gravity being applied.
Either remove the gravity scale or even better,
you can make the whole object either kinematic or static.
I would recommend static because static means it will never move
and obviously our map shouldn't move unless you want to,
I don't know, add the rotating map.
Weird thing that we just experienced.
So with that done,
pause the video right now,
go do the Chaldean.
Okay, welcome back.
So how did you get on with that?
I'm going to go ahead and whereas the walls rigid body make the static, run the game.
And now we should see that there is nothing falling anymore
and all the colliders work perfectly fine.
Okay, with that done, I hope you enjoy it.
And in the next video,
make sure to create some kind of map.
It should be bigger than the camera because we will be implementing a fall camp.
So why is that?
Well, if I let's say add a bit more ground here,
make sure that we have the ground selected.
I add the ground.
Let's see if I make this a huge ground.
I run the game. I want to be able to walk around our map and runway,
just like the game that we saw in the beginning.
So I want to have the freedom to walk around.
But obviously, if I look in the game menu,
I cannot see anything.
I can see it in the scene mode.
I can not see it in our game. Why?
Because the camera right here,
you can see, let me just this is the camera,
this is the main camera,
so we will have to move it around so we can always follow the player.
And that is something that we'll learn in the next video when it comes to cinema cine,
I hope you are enjoying,
I hope you are always committing your changes.
And I hope you've left a review because it helps me out a lot.
See you in the next video.