Hello, guys.
In this video, I want to improve sound effects system, and for that I want to play another video from
my insider course where we're doing basically the same, just it has more suitable environment for explaining
why we're doing it and how does it work.
But after we watch this video together, we're going to implement same system in this game.
So let's just watch it.
And after that, let's implement it in this project.
It's nothing difficult.
It's basically one line of code that changes everything.
But still, what I'm trying to say here is just that game has different player controller and it's easier
to explain with more control of the character.
Right.
Okay.
So let's watch the video.
Hello, guys.
In this video, I want to tell you, how can we make sound effects sound differently every time?
Because at the moment, if you pick up, let's say, six fruits in the row, it's going to sound like
that.
Wait, I'll switch of the music.
Yeah.
So it's going to sound like that.
Very same.
Right.
But every sound has a peach effect over here.
If you ever worked with the music, you might know what is a pitch.
So this the sound we play when we pick up items and there is a pitch.
So if I increase it to the big one and the increase value to really big one, just to make a point.
And let me take my player and pick up one of them.
Sounds like that.
And if I make it lower.
Not like that.
Boom.
You hear it?
My comment and then like this.
So every time it sounds differently with a different pitch and we can control the speech from the code.
Let's go to our audio manager.
It's over here.
I'll do close all but this.
And right before we play the sound, I'm going to do SFX.
SFX to play.
Dot peach equals to random range from point 85 to 1.15.
Let's say it should be not really a big difference because otherwise sound will be very different and
that's not what we need.
We need it to sound similar but different every time.
Right.
Let's go and test this.
So I'll try to jump many times.
Where is the music?
So jump sounds differently every time.
And when I pick up fruits, it sounds differently as well.
Let me make more of them.
So it is really easy to notice.
Now listen to this.
Yeah, it sounds different every time.
And, you know, these kind of things.
What makes game really good?
Because player will not notice it.
I'm telling you, nobody will care.
But people care if it's not there.
This is how it is.
Like if it's not there, people will notice, people will complain, but if it's there, nobody notice
and everybody is happy.
So details like this should be in the game to make it feel better without player even knowing it is
there.
Right?
So now every sound sounds differently and you're not getting tired of the sound.
And I guess we should make jump a little bit lower in the volume.
All right.
Yes.
So as we understood, we're just going to change each of every sound effect when it's played.
And we're going to do that by putting random value in it.
So let's go to audio manager.
We're going to find our play a function over here.
We're going to do this.
A suffix with the index.
Then dot each equals to random range from point.
Let's try 85 F to 1.1 F, something like that.
Now I'm going to go and pick up some coins.
You already can hear jump.
Sounds different every time.
And coins.
Yeah, sound is different.
All right, let's go and do the settings.