audio.Source.Stop(); giving me errors

I added this line to my code and followed along exactly as the lecture, but now I am getting errors. Below is a clip of the code, and a screen shot of the error messages.

        switch (collision.gameObject.tag)
        {
            case "friendly":
                // friendly = do nothing to rocket
                break;
            case "Finish":
                state = State.Transcending;
                audioSource.Stop();
                audioSource.PlayOneShot(success);
                Invoke("LoadNextLevel", 1f); 
                break;
            default:
                state = State.Dying;
                audio.Source.Stop(); //stops thrust sound
                audioSource.PlayOneShot(death);
                Invoke("LoadFirstLevel", 1f); 
                break;             
        }

Hi,

I can’t see any details from that image (using my mobile), but you have an extra dot in audioSource.Stop(); in the default case of your switch statement.


Updated Tue Oct 30 2018 22:46

I have seen the image more clearly now, both of the errors relate to the typo mentioned above. Remove the dot between “audio” and “Source” and the errors will be resolved.

Hope this helps :slight_smile:


See also;

2 Likes

Thank you!! Oh man, I can’t believe I missed that little detail. Thank you so much!

1 Like

It happens :slight_smile:

You’re very welcome and I am glad you can move forward again.

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

Privacy & Terms