Cool, so it's time to add some simple sound effects to our game. This is also very easy. So let's actually get rid of our ground because we don't need that anymore. And our water, the two things that we took off, not these guys, but the two, two objects, we turned off another earlier episode. And we can save and then all we need to do is go to our player, and we need to add a component to our player called audio source. And then we can go inside about audio.
And we can actually go back and click back on Play and we can actually drag our theme song to our audio clip section and we can press play. Cool, so that's working just fine. Then we can open up our player script. And we can create two new variables, public audio clip, and we're going to call this score up Another one public audio clip damage. Cool. So then we did another on trigger enter function.
So if we go over to score, we can actually highlight this again, and we go back to play. And we can go underneath the update. dump that in there, we don't need this. And if other gamers are tag equals score up, that's actually exactly what we need. So we can just write our audio code in there. So we can say get component.
So once again, this is getting the audio source component, audio source, just like we did in earlier episodes. And we can say, What do you saw stop, play one shot. And we can say what clip Do you want to play we want to play score up and just 1.0 f volume Cool, and let's just copy this copy and we want to change this from if other cameras attack equals triangle. We want to play the damage sound effect. So let's go back over to unity. First of all let's make sure our prefabs make sure our triangles actually are tagged with triangle.
Yep, they are tagged with triangle and the gaps are tagged with score up okay, everything is going fine so far. And then we can go over to our player and we can assign our score up and our damage variables and they will just be in SF x so go back to player and go down. So score up. Score plus one and damage as damage. Cool. Now this won't work.
How we think is going to work just yet. Because on our prefabs, our prefabs have a mesh collider. And this is actually a mistake because a gap will work fine. And we can actually test that because it's a trigger. But these are not triggers. And in fact, they're probably we probably don't need a mesh collider because there's such simple shapes anyway.
So to fix that problem, we just need to click on these to click on all the triangles within these prefabs we can remove the mesh collider remove and add a box collider because it's such a simple shape they should fit perfectly and we can just test it by dragging it in. And you'll see here that the box collider is pretty much perfectly around both objects. That is exactly what we want and do that for the other two. Let's change the prefabs remove the mesh collider. Add a box Collider. Make sure we click is trigger.
That's the other thing that we need to do. And third one now. Remove mesh collider add box Collider. Tick is trigger. Cool. First of all, let's remove the triangles.
Cool. And just for the sake of our own sanity, let's go and mute the audio source. Just so we know what's working now and we don't need to hear it every single time we play the game. So let's just meet that. Cool. So things seem to be working absolutely perfectly.
We have our theme song, we have a noise every time we the score goes up. And when we run into something, we get the big fat as well. Of course, we just pass through the game objects now. And that is fine because what we're going to do is we're going to actually write some code for our game. For when for what will happen when We actually bumped into one of these triangles. So don't worry.
We'll fix this in a later episode and we'll see you there.