Search Unity

Audio No Audio after loading scene in Karting Microgame

Discussion in 'Audio & Video' started by nitrous821, Jan 4, 2020.

  1. nitrous821

    nitrous821

    Joined:
    Dec 20, 2019
    Posts:
    3
    Hi guys,

    I've been newly introduced to Unity and tried out the Karting Microgame project. I want to restart the scene as to replay the track. So I input
    "SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);".
    The scene reloads and it works but all the audio [The engine, drifting and collision sounds & background music] are all silent.

    Any idea on how to fix this?Thanks

    P.S. First time posting here so if I do something wrong, I apologize.
     
  2. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    Welcome @nitrous821 !

    So I tried this myself and it seems to work just fine for me. Specifically, I went to the Karting microgame project and simply wired up a button with the following code:
    Code (CSharp):
    1. public class RestartTrack : MonoBehaviour
    2. {
    3.     public void RestartLevel()
    4.     {
    5.         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    6.     }
    7. }
    For me, this all seems to do what you'd expect, including restarting the audio. Is it possible that you've done some modding along the way that might be causing the problem?
     
  3. nitrous821

    nitrous821

    Joined:
    Dec 20, 2019
    Posts:
    3
    Hi there,
    Thank you for your reply!

    I tried as you did to double-check if my version of the karting microgame had the issue but even in the new project of it, my audio does not work. Back on my main project, I created 2 extra scenes, "Title" & "MainMenu", and when I switch about those 2 scenes the audio has no issue. Only when I enter back into the first sample scene, no audio can be heard but when I switch back to either scene, the audio resumes.

    Any advice to tackle this issue?
    Thanks!