Sound Working Normally on Level 1, but Level 2.....?

Does anyone have any idea why my sound would work perfectly on level 1 but not level 2?

I tested first level, and correct audio will play on free fall and if I was holding space. But on level 2 the collision and success audio will only play when holding spacebar… I’m not sure what’s causing the issue since the scripts don’t change and my entire scene was duplicated… I also made sure I updated my prefabs as well.

Collision.cs

void StartFinishSequence()
{
    GetComponent<Movement>().enabled = false;
    if (audioSource.isPlaying) 
    {
        audioSource.Stop();
    }
    audioSource.PlayOneShot(finish, 1f);
    Invoke("NextLevel", levelLoadDelay);
}

void StartCrashSequence()
{
    GetComponent<Movement>().enabled = false;
    if (audioSource.isPlaying)
    {
        audioSource.Stop();
    }
    audioSource.PlayOneShot(crash, 1f);
    Invoke("ReloadLevel", levelLoadDelay);
}

Movement.cs:

void ProcessThrust()
{
    if (Input.GetKey(KeyCode.Space))
    {
        rbody.AddRelativeForce(Vector3.up * upwardThrust * Time.deltaTime);
        if (!audioSource.isPlaying)
        {
            audioSource.PlayOneShot(engineThrust, 1f);
        }
    }
    else
    {
        audioSource.Stop();
    }
}

Hi rhea,

Welcome to our community! :slight_smile:

Are there any error messages in your console in level 2? Have you already tried to add Debug.Logs to your code to see what is going on during runtime?

Hi Nina!

Thanks for your input, but I actually figured it out. Apparently at some point I manually added movement.cs to my level 2 rocket even though it was already saved in my prefab… :woman_facepalming: a little embarrassing lol but I removed the duplicate and it’s all sorted now.

Thanks again! :slight_smile:

Good job on fixing the issue! :slight_smile:

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

Privacy & Terms