I’d like to have my audio source carry over for each “castle” level, but if the player goes to a non “castle” level, i’d like for the audiosource to be destoryed. I’m not sure how to get the level names into the code though.
public class CastleMusicManager : MonoBehaviour {
void Start () {
DontDestroyOnLoad(gameObject);
}
// Update is called once per frame
void Update () {
if(Application.loadedLevelName != "Castle1" || "Castle2" || "Castle3")
{
Destroy(gameObject);
}
}
}
Something sort of along these lines.