No sound playing

I’ve added \GetComponent< AudioSource>().Play(); " into my script FinishLine. And added the audio file to the audioclip section in audio source in the inspector. I don’t have the game window on mute but I still can’t hear the sound playing when I cross the line. I can hear the sound when I double click it in the assets folder. Any ideas?

Hi,

Welcome to our community! :slight_smile:

Good job on analysing the problem so far and for mentioning what you figured out. Otherwise, I would have suggested what you already tried.

Does “You finished wahoo” appear in your console? If so, I would suggest to comment out the line with Invoke and test your game again. Maybe the next scene gets loaded too fast. All non-persistent game objects get destroyed when a new scene gets loaded. Maybe that is also the case here.

If the sound plays after you commented that line out, increase the restartDelay value in the Inspector and remove the // so your Invoke method will work again.

1 Like

Welcome to you

Does the log message “You finished wahoo” appear in your log console


restartDelay is set at 4, I tried again commenting out invoke and that didn’t help either.

I noticed that the “You finished wahoo” message is getting sent twice. I think this might be related to the problem?

I have activated the option ‘Play on Awake’ but I don’t hear the sound when enterting play mode, so I’m starting to think it’s an issue with the sound? I’ve tried multiple sounds, but am stuck really :confused:

Maybe you could add the Start method to the FinishLine script and play the audio source there. This way, you’ll immediately know if the problem is in the OnTriggerEnter2D method (or because it was called twice) or if there is a problem in the Unity editor.

Also expand 3D sound settings in the AudioSource component. And set the volume to 1 in the AudioSource component.

And check the Main Camera game object. Is there an AudioListener component attached to it?

Ok I figured it out!

The issue was with the pitch? When I set the sound to loop I could hear the sound playing. It was slow and long but I could hear it. I changed the pitch to 1 and it sounds as normal.

Still unsure why the sound doesn’t play when the pitch is -1 and without loop on?

To be honest, I don’t know it either. You are using a fairly old version of Unity, so maybe you were just experiencing a bug.

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

Privacy & Terms