Multiple Audio Issues happening for Project Boost

Hi,

For this lecture I’m unable to get the multiple audio working, only the thurster sound.

Can you please tell me where I’ve gone wrong? I can’t seem to figure it out Thanks!

 private void OnCollisionEnter(Collision collision)
    {
        // Will prevent the dying console message from appearing more than once
        if (state != State.Alive) { return; }
        
        switch (collision.gameObject.tag)
        {
            case "Friendly":
                break;
            case "Finish":
                state = State.Trancending;
                // Load the next scene after 1 second
                Invoke("LoadNextLevel", 1f); // parameterize time
                break;
            default:
                state = State.Dying;
                audioSource.Stop();
                audioSource.PlayOneShot(death);
                print("played!");
                Invoke("LoadFirstLevel", 1f);
                break;
        }
    }
1 Like

Hi,

Welcome to our community! :slight_smile:

Are there any error messages in your console during runtime?

PlayOneShot cannot be stopped, and you cannot play multiple sounds simultaneously with the same AudioSource. You need multiple AudioSources to play multiple audio clips at the same time.

No there’s no errors in the console.

Just to confirm I can hear the Success and Rocket sounds, however not the sound on destruction…

  1. Remove the reference to the destruction sound from the field and readd it.
  2. Add a Debug.Log to the code block where the destruction sound is supposed to get played.
  3. If nothing helps, assign a different sound to the destruction sound field. It does not matter which one. You do this to figure out if the AudioSource plays the sound assigned to that field. If it does, there might be a problem with the destruction sound file. If it does not, there is a problem in the code.

I had this excat same issue and I tested out things like you reccomended @Nina . even before reading this post. assigning a different sound did not help at all. in fact i have a print statement that works just fine in that line of code as well as the scene resetting works perfectly fine when i die. it’s just the sound does not play

That’s good, @Carlos_Felipe. You know that your method gets called as expected. Comment out the line with Invoke and test your game again. If the sound is played, the problem is/was that the new/next scene gets loaded too fast. In that case, use a higher value for the second argument.

I found my issue was a dumb programing mistake I somhow had left a audio source stop() in there where i shouldnt have really dumb mistake but somehow i missed it thanks Nina

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

Privacy & Terms