- Home /
Music resets upon level reset
I have a game where when the character dies it resets the scene using Application.LoadLevel(Application.loadedLevel);
Every time the character dies the music restarts as well. I would like the music to continually play without restarting even if the scene resets.
If it helps the music player is a child of the main camera and is named GameMusic and has the tag GameMusic
I know this question has been asked before but none of the solutions I've seen seem to work.
You can check this out from scripting API. And even better, you can create a singleton class to manage your AudioSource, which also doesnt destroyed on load. By this way you have the full control of music.
I've tried this solution before but it doesn't seem to change anything and it doesn't even create two audio sources like others have reported. It still resets as normal.
void Awake()
{
DontDestroyOnLoad(transform.gameObject);
}
That's the code I'm using
Answer by vivalde_ · Apr 24, 2016 at 07:35 AM
I continued looking and found that Reder13's code worked perfectly. http://answers.unity3d.com/questions/878382/audio-or-music-to-continue-playing-between-scene.html