Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

Problem with audio source playing on awake

$
0
0
I have my audio source set up on an empty gameObject with this code in the Update function: if (Application.loadedLevelName == "mainMenu") { Destroy(this.gameObject); } else DontDestroyOnLoad(this.gameObject); When I die, it takes me to a retry scene, I don't want the audio source to be destroyed unless it goes back to the main menu, the probelm is, when I click retry and reload the level, the empty gameObject audioSource carries over, but then another instance of the audio starts and there's two copies of it playing. Is there a way I can get around this? Thanks

Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>