We'll be making some collision stuff and with this, we can do a lot of stuff! Like if a car scratches a wall create sound, if a character is hit he makes noise, if he jumps make jump sound, and so.
We'll be doing this: when the charecter picks up a coin, a sound plays (you know what sound it is).
Take a model from the internet, one of the cool asset site is OpenGameArt, it got lot of cool stuff like textures, sounds, characters, and more! Okay now back to our business, take a sound from that website and fire up the engine.
Yes, we want our player to get the coin and play that sound. So, make a player setup with which you can move and do stuff or you can get one from here. And then we'll be making a coin that disappears when the player hits it and plays the coin sound.
Add an object that represents the coin (or you can model a very simple one by adding a circle, filling the circle with a face and extruding) and keep the coin selected.
We can detect this collision stuff by either by material or property. Let's get our hands dirty with property. Add a property to our player by opening up properties panel or that side thing that shows up when you press N
You can set it as float, int, timer, bool or str. Leaving as it is recommended (which is float by default).
Select the player, add a Collision sensor. Add a sound actuator, connect them both and select the sound which you want to play. In the Property field, type the name of the property of the object that represents coin (we renamed it as coin). Just in case if the audio doesn't play fully, in the sound actuator that plays the coin sound, set the Play Mode to Play End.
Let's run the game to see if that really worked lmao
mmm... the sound plays but we forgot one thing. Which is to make the coin disappear! Let's select the coin, turn on Ghost in the Objects Physics. This actually makes the coin like ghost, which can clip into objects not reacting to collisions but can detect collision. Almost ready, make sure you have the coin selected (sorry lol) and add a collision sensor. Click on the M/P which toggles the mode that looks for a certain material. Click on that field and select your player's material. Add an Edit Object actuator, set the Edit Object to End Object.
This means, the coin looks for an object that has that player material and if that object collides, the coin ends it life. Don't forget to connect them, only then it works. Now run the game!