Hello guys.
Welcome to the video.
So we basically done with this section.
There is nothing much to do and we don't really need to do any cleanup because I try to be careful.
And we did not write lots of code here so it should be fine.
I just want to congratulate you, maybe because we are pretty close to the end of the course and I know
it's a big achievement.
So yeah, sorry, that was not very enthusiastic, but I'm really happy and I congratulate you.
So yeah.
Good job.
Now I'm going to wrap this project into archive.
I'm going to give it to you if you want to compare it to yours.
And I'll just do this I'll disable settings and I'll enable main menu like that.
And also before I give this project to you, I'm going to go to audio Background music.
And I'm going to delete these two tracks just to make my project lighter.
And if you need them you know where to get them.
You can just download them from the asset store.
Now you'll have these tracks over here, but it will say Missing Audio Source, so probably you will
not be able to play it.
Maybe just in case.
Let's go.
To the audio manager.
And when we play BGM over here, we're going to do this.
If BGM dot length is less or equals to zero, then return.
So we will not start this invoke repeating method and we will not do check for the BGM and maybe we
can do same here.
I'm going to do.
If BGM dot length is less or equals to zero, then I'm going to return and I'm going to say debug log.
Warning.
You have no music on Audio Manager.
All right.
Just to protect ourselves from a possible mistake.
Oh, yes.
And something else.
Something important.
I forgot about this.
If you go to the scene right now, it will not have an audio manager.
This one will have.
But for example, level two does not have an audio manager.
And once you start the game, it's going to try to request audio manager.
And you're going to see an errors and game will not work as needed.
So somehow we need to bypass this limitation.
We can go to prefabs and make game manager as a prefab.
That's first step.
And let's change the name to.
Uh, game manager with the underscores here.
Okay.
One, two.
Three underscores.
One.
Two.
Three.
Okay.
And we're going to go to game manager.
And we're going to make a reference to the prefab of audio manager.
I'm going to make a header.
Managers.
And then I'm going to do serialize field private audio manager.
Audio manager.
Then we need to make a method that would check if we don't have audio manager in the scene.
Let's go and make a method.
And to this private void.
Create managers if needed.
And then inside of this method.
This method is going to be called in the start.
Once all of the instances are supposed to be assigned.
And because of that, we can check if we have an instance of audio manager, and if we don't, we have
to create it real fast.
And this is how I'm going to do it.
I'm going to make.
If statement.
If audio manager audio manager dot instance is equals to null means we don't have it in this scene,
then we can do instantiate.
Audio manager.
Just like that.
Let's go to start method and do, uh, create managers if needed.
And I believe it's supposed to work, but maybe it will not let me just.
And double check it.
We need to go to the game manager.
We need to find prefab of the audio manager.
Drag it here, then we need to apply overrides so it has auto manager on all of the prefabs.
Then we need to go.
Let's just check it first.
Let's go to play mode.
And it works.
It's fine.
And we have audio manager here.
All right.
This is good.
Now let's go to asset scene level one.
And over here.
We need to delete this audio manager and replace it with audio manager that we have prefab I mean game
manager.
Game manager.
Okay.
This one can be deleted and game manager is here.
We don't have respawn point assigned but I believe it's supposed to be done automatically.
Is it done automatically?
No, it is not.
Let me check.
Start point.
It is not okay.
We need to find start point if we did not assign it manually.
Just in case.
Um, for now, let's do it like that.
Landstorm if respawn point is equals to null.
Then respawn point equals to find object of type.
Start point.
And it shows me an error because it was changed.
A new unity version.
And we need to do find first object by type.
Okay, I'm so sorry.
Not off type, but by type.
Find first object by type of start point.
Transform.
Okay, so this will find the respawn point if you forget to assign it manually, right?
Let's go back.
And I'm going to go to game mode.
Respawn point is empty.
Okay, we need a respawn player.
There is audio manager.
Everything is good and we need to replace it on other levels.
Let's go to scene level three.
Save it.
When I go to a prefab now, I'm going to go to prefab folder.
I'm going to drag this game manager over here and this one can be deleted.
Okay.
Something else.
Probably no asset seen level four.
Yes.
Let's save the changes I'm going to delete this one.
Going to go to prefab and take Game Manager over here.
Cool.
Now let me double check it on this level.
Okay.
There was some error.
Let me see.
What is it?
Enemy mushroom cannot update reference to the player.
Uh, for some reason.
Because this field is empty over here.
Okay, let's quickly fix it.
We're going to go to game manager and do the same for the player.
And just in case, later on, I think I'll find a better way to manage this.
Just in the next section we're going to do it in a bit cleaner way.
But as of now, let's just fix the problem that we have right now I'm going to do.
If player is equals to null, then player equals to find first object by type player.
And that's it.
Yeah, I know it's a clean up video and we could do it now, but this is more about audio manager.
So yeah, we were fixing audio manager and this just got in the way.
So we fixed it quickly.
In the next section I'm going to show you how to make it better.
As of now.
Let me just double check.
Okay.
No errors.
Very cool.
Nice little design, by the way.
Good job.
Alex.
Yes.
The end of the game.
Okay.
Great job.
In this video we created the manager.
We cleaned up a couple of.
We created a manager, we cleaned up a couple of errors we had.
And that's good I'm going to wrap this project into archive.
I'm going to give it to you and I'll see you in the next section.