So now that we have our game playing correctly and turn my music down here we've added our SOUNDS IN.
BUT YOU SHOULD HAVE KNOWN IT WAS A ONE LITTLE BUG this happening which is if I play here.
If I'm moving and I stop or not stop put pause the game are walking sound effect is still playing and
that's obviously not Grace.
So this is your next challenge.
How can you fix this bug.
It's very easy to do and we can do it with knowledge that we already have in our game but it's up to
you how you think you can apply this to the game.
So as we've done before I'm gonna tell you to go ahead and try and do it yourself.
And then I'll do an example of how I could prove how I could solve the same problem.
So go ahead and pause the video now.
Okay.
So we want to make it so the footsteps sound effects stop when we pause the game and how we're gonna
do this is by better telling.
I will have a reference to those sound effects on our player and we'll tell them to stop playing whenever
the game is past.
So relatively simple and straightforward to do so we need a reference to both of them in our player
controller skit because we know we have our two footstep sounds here so we're gonna go to play our controller
and what we're going to do then is at the top of the scripts we're going to create two references so
public audio source
footstep fast and footstep slow like so.
And then when we go to when we pause the game we do that on our game manager here.
So here is where we pause the game.
So we're gonna say player controller that instance does footsteps fast stop and play controller that
instant stop.
Footsteps slow stop.
I'm going to save this and go back into unity and then once this compiles we'll just test and make sure
that that works correctly so obviously we need a rep to put these into our player controller first of
all so fast we'll go in there and slow.
I did slow and run one fast.
There we go.
So let's go ahead and play this.
And now when I run I pause.
There we go.
We get our sound stopping.
And if I resume the game now you'll notice I am still moving but our sound effects aren't playing so
we need to fix that so I got to jump back into our player controller script and it stopped us running
back into player controller.
Are not the player controller we need to go to the game manager and what we'll do is simply when we
resume the game we're going to do basically the opposite that we had here so I was going to copy this
and paste it in here and we're just gonna say play on both of them and we can do play on both of them
because it doesn't matter whether they're active or inactive if they're inactive then playing won't
do anything because there's no sound to play there's no sound at activation in the scene but if one
of them is activated then it's going to play that sound again as soon as we resume the game.
So let's save this.
We'll jump back into unity once that compiles that we go.
I can go no matter what I select here but now I can run and if I pause we guess the sound disappears
and if I resume the sound immediately comes back it's perfect.
We've now fixed that little bug and hopefully you manage to work out how to do it yourself as well.
And it wasn't too complicated.
As you can see it's a very very simple solution to do.