Welcome back my fellow game developers
to a brand new video.
And this is truly one of
the coolest videos we've ever made so far, in my opinion.
So what we're going to do is we're
going to just run the game.
And before I do that because we are experimenting,
I'm just going to move this door out
of the way around again.
So we're playing, we open the door
with some type of killing and whoa, we come here.
What is that?
Wow, a portal.
What do you think would happen if
I tried to maybe jump it?
Well, What happened?
Well, we are at level 2 or I mean at level one,
we were at level two,
should have pointed that out,
but you can see right here that we do start in
level two and then we go to level 1.
We learned about portals,
we learn about sin management,
and we learn how to use a string variable.
So let's not waste any more time.
Let's get started.
Oh, so time for some level of flow.
And the first thing that we need for the level flow as
the scene management and the way we manage
scenes is through a scene manager,
how convenient is that?
But before we do all of that,
the first thing that we need to do is
actually create some type of portal.
So a portal that will take us to another level.
Now, before we do that,
we need an actual other level to go to.
So I'm going to go into the scenes in
here and I'm going to duplicate s2.
I'm going to open it up.
So now we have seen three.
It's the same, it's exactly the same as the s2,
but all I'm going to change are the tiles on the ground.
So I'll go into tile palette.
I'm going to choose ground,
and I'm going to make this a color of green.
And I'll just change this up a bit.
There you go.
So that's a bout what I want to do.
I'll cover this part,
this part,
and this part just so we can differentiate between them.
I don't want to spend time
creating a whole different level.
It will take a lot and there is no actual purpose,
but for you while creating your game,
I do recommend that you
go through the hassle of doing it.
It's good practice if you want to
create your own game from the styles.
Enough talk, let's get started.
Save that. Let's go back to Test2.
So now we have the friends between test2 and test3.
I think it's time to call this level 2 and level 3.
So Level 2, level 1 or no.
Let's keep this as a, this was actually a test.
And level three.
Actually, this should be,
okay. Wait a second.
Let's keep this level 3.
Sure, we load, this will become level one.
And this one is level two.
So we have just one,
level one, level two, okay,
so back in level 2,
and here we are going to have some kind of exit portal.
I've provided you with the resources for the portals,
and I chose this one.
And you can see that you have
25 or 20 portals, I don't know.
And you also have this green one,
but I'm going to use the 15.
Was it 15 year?
It was 15.
So back in here in the sprites,
right-click Create Folder, portal at Enter.
Double-click in here, and I'm going to add all of
the images and wait for them to be added. Very good.
I'm going to right-click create
an empty game object which will be called
the portal enter specter.
Set z to 0.
There we go.
Let's move it in here.
Add a component or what?
Let's not add a component.
Let's add a animator.
We're going to go to the window.
And actually, before we do that,
let's add one of the images in here to the portal.
Can we add it immediately?
Nope, can't.
Let's add a sprite render.
And we'll add just this image right here.
And let's set it as the player. And there we go.
You can see it's a bit small.
Let's choose all of the images and make them 50 apply.
So it will double in size, okay,
girl rate and make it point.
Will it become better? Let's zoom in and see
sometimes point is not the best filter.
Sometimes you keep it bi-linear,
it's butter, and in this case it is.
So bi-linear, they are smoother,
you'll notice now it's a bit smoother.
I like it better, do whatever you want with it.
And you know what?
I'm actually because the room is already big,
I'm going to make it 25.
Yep, there we go.
Okay, 25 is good. Nice.
So there we go. We have this portal right here.
Let's go into the window.
Animations, animations.
So we've already covered how we do this.
I'm not going to go into too much detail.
I'm going to create assets, animations, portal.
Make sure to always create
folders and keep everything small.
So portal swirl.
Or this will be just the animator
or nano, and this is the animation.
Swirled because the portal is swirling.
I'm going to select all of these and drag them in here.
Now when we play, there you go.
I think this is good enough.
You don't need to make it bigger or smaller.
Excellent.
So now we have this portal working.
The next thing we're going to do is obviously we'll
add some kind of Collider in here.
So add a circle,
circle collider 2D, and it's a bit big.
Let's make the radius a little
bit smaller so the enemy needs, the enemy,
the player needs to jump into the portal immediately to
be teleported to the next level
or whatever level that we want to tell apart too.
And this is the part where we choose which,
where do we want to be teleported?
Is it always the next level
doesn't have to be because later on in the,
I believe the section where we generate levels,
I think it's the last one.
We will be choosing
random levels just like we have in Hades.
So we'll create different types of layouts,
have different types of levels that we go through.
So let's go into the scripts.
Let's add a script in here for the portal.
We're going to call it level exit.
Let's call it the levels,
level flow that will slow.
I think that's good.
Right-clicking here, create a C-sharp script
which will be the level exit.
I don't even remember if we will be having
other scripts related to level SOPA.
Let's keep it at that.
So I'm going to click on here.
And of course we are going to make it a trigger.
This collider should be a trigger.
And let's add the level of exit.
And finally, I'll go into the Prefabs and I'm going to go
here and create a prefab for the,
should I just make a portal in here?
Let's say we can add, create in here,
something like maybe, okay,
let's just make the portals, portals.
Open this up. Portal.
And maybe portal one, maybe non port one.
Let's just keep it at portal, save all of that.
And now let's open up the script in here.
So we have the level exit opens
up and what do we want to do in here?
So the first thing we want to have
as obviously a serialized field,
which is going to be a string of type string.
This is the first time we create
a variable of type string, I believe.
And this is going to be the level to load.
Great, so now we can go back in here, shows the portal.
And we can select the level that we want to go to.
And the way we do that is we need to make sure that
we get the exact name that we want.
So and scenes we copy, for example,
level also we are on level 2 right now.
And it weighs no worries.
Let's go and two,
we go from level two to level one. Sure. Why not?
So we are going to lock this down,
select level to select Level 1.
Copy this, paste it in here.
Oh, no, wait, wait, wait, wait.
We should select this one and now we copy it here.
So now this portal,
when we trigger it,
we should go to level 2 load.
But how are we actually going to do this?
I'm going to go back in here.
And let's remove start an update for now.
Just for now we'll later on need them course.
And in here I'm going to create an entrepreneur
enter d. We already know how this works.
We are of course going to make sure that the collision,
the tag, is equal to Player O.
So now you're thinking,
Oh, Michael, well what's this?
What, what is the compare tag?
Well, you can use compare tag is much better,
but I wanted to show you a different way
and now it's time to load the next scene.
How are we going to do this?
How do we actually move from one scene to the other?
Let me show you just a little bit.
So this is the scene manager
and you can see right here that
we have a lot of things that we
can use static methods, events.
I'm going to leave it to you because later on in
just a bit we will have a small challenge.
But what I will help you with is that I'm going to make
sure that in here whenever we want to use scenes,
we need to add the using
Unity engine dot scene management.
Save that. And now we can do a lot of things
with our scenes or we can actually manage our scenes.
So before I'll issue you
the challenge of finding which method
we are going to use or how can you use this unity?
Where is it the scene manager?
I'm going to show you how
to actually access and because I
want this challenge for you to
work immediately when you start.
If you go into the file right here we
have something called the build settings.
If we click on it, we can see the scenes in built.
And this is where we actually build our game.
And you can see that we have multiple options.
We can use Windows,
we can use iOS or whatever this is,
tvOS, ios, PS4, PS5,
xbox One, et cetera, et cetera.
You can create things for different platforms,
and the PC is the one that we're going to use.
We can do different things.
And this is where you add
all the scenes or
the levels that you'll have in your game.
So for now, the only scene that is
added into the bill is the scene test1.
And without adding season here,
you will not be able to travel from
one to the other using Scene Manager.
So well that clear,
I'm going to add the level one.
And we can also do this by AD open scenes. There you go.
You can see at the scene 2
because it's an open scene. Okay.
Great. Can we added another time?
No, we can't.
And you can see also that
these scenes have indexes on them.
We'll not be using indexes of the scenes right now,
but keep it in mind because later on they will come up.
So settings, save that again, File BuildSettings.
There you go.
At all of the scenes that you have whenever you want to
use Scene Manager to go from
one to the other, close that.
Now, what are we going to do?
We are going to issue you
the challenge to load the next scene.
So look through the scene manager
in Unity's documentation,
find the appropriate function that
can help us go to a different scene.
So this is astronaut use.
And finally, make sure it's a method that
uses a string as an argument.
So pause the video right now and go to the Chaldean.
Okay, Welcome back.
So let's say I am a student
of Michael Moore and I'm just more,
more what everyone's saying.
And I'm just learning how to use the scene manager.
Okay. What is the goal, what is the challenge?
He asked me that I should
load the next scene. Okay, great.
Let's look. What do we have?
So we have seen count,
seem counting building doesn't look
like it helps create seen.
Nope.
Gets seen. Nope. I don't think that's held.
Gets in at no.
Building by name, gets seen.
Load, load a scene,
loads the scene by its name.
Wait, what was the challenge?
String as an argument, o k.
This is a bit faster than I should, but no worries.
Load scene, Let's click on Load seen.
Hopefully we have Internet will do so.
Declaration, okay, we load seen.
We can use the symbol index or we can use the same name,
excellence, you name, name.
Scription loads the scene.
Excellent, This is what I'm going to use.
So now on Trigger Enter,
if it's the player,
what we're going to do as we are going
to see how this is actually done.
So if I scroll down in here,
okay, So scene manager dot load seen them.
Is there something else I need?
No, nothing.
Let's continue on.
Or maybe at this point you might be thinking,
well what is this load seen Moldau additive?
Well, if you don't know, let's just try it.
So scene manager, dot load scene.
I'm going to open the brackets and I can see right
here these one out of six.
So the scene build index.
Nope, I don't want that.
Okay, see you name this is what I want,
but we have four others and
this is a good time to teach you that.
Sometimes a method can take
12 or maybe even more arguments
based on what you give it, it will work.
So for example, we can add the mode.
You can see right here, load Scene mode,
this is what we were talking about right here.
So load Scene mode, additive.
I don't even know what that is.
But in here you can see that there is an option for it.
Anyways, this was a side note.
What do we want to use?
Which scene?
Well, we already have it with the level to load.
So Lovell to load
as this scene that we are going to load.
So everything should be working fine.
I'm going to go back into Unity.
Save that, make the game a bit bigger.
Also, I need to kill all the enemies.
And honestly I don't have time to kill all of them.
That's just get the doors get swung open, run the game.
Also, it's going to close in any case.
And we have these lines, okay?
So first of all, don't maximize on play.
Now run the game.
These lines are bothering me a bit,
so I'm going to choose door 1,
I'm going to deactivated.
I'm going to walk through why it is that can I shoot it?
I think I can.
It doesn't get destroyed. No, it doesn't.
So if I walk closely,
you can see I'm at level 2,
I'm off through it to 0.
What happened? What happened?
I am at level 1.
Wo, how cool is that?
Seriously, guys?
This is one of the coolest things
that have happened today.
We suddenly moved from level
2 to level 1 through a portal.
Very nice.
So now everything is working,
but it's very fast.
And honestly we don't want to happen that fast.
We want to make it a bit slow and add
a bit more character to the game as we move through it.
So I'll see you in the next video.
Of course, don't forget to commit your changes.
Look how far we've come.
Look why I love committing my changes.
Well, we started with an initial commit,
added idling and hast animations
created player added bullets,
created animation for the enemy,
damage, enemy deterioration.
I don't even know what the lock,
how much we have
accomplished and we are maybe not even halfway.
Well, very nice.
So I hope you're having fun,
I hope you're enjoying and I'll
see you in the next video.