Problem with sound effect

Hello!
I’m building up the game Snowboard. I already have sound effects added as Rick showed: crash effect when my dude hits his head and finish effect when he finishes a level. I added the coins he collects (they disappear like in a car game :wink:). I want to add a sound effect to the disappearing coins. Audio is added to the coins in unity (add component) Is the problem that this effect is already exploited?


Have a nice day for everyone!

Hi,

To be able to use a variable, you have to declare it within the scope of the code block where you want to use it. Furthermore, when a game object gets destroyed, all its components and children get destroyed along with it. If the AudioSource gets destroyed, it cannot play any sound anymore.

With these two things in mind, I’m sure you’ll be able to solve this problem. If not, please let me know. :slight_smile:


See also:

Thank you! I’ll try to fix the problem, your tips are awesome :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms