EDIT I just saw your edit, I’ll give that a go.**
Hey Mosjmosh, thanks for your reply.
I do have the MusicPlayer script set up like that, attached to the MusicPlayer object in the Start scene:
using UnityEngine;
using System.Collections;
public class MusicPlayer : MonoBehaviour {
static MusicPlayer instance = null;
public AudioClip startClip, gameClip, loseClip, winClip, bossIntro, bossFight;
private AudioSource music;
void Awake (){
Debug.Log("Music player Awake " + GetInstanceID());
if (instance != null && instance != this) {//Once we claim this as an instance we do not want to destroy it obv
Destroy (gameObject);
print (“Duplicate Music Player Destroyed!”);
}
else {
instance = this;
GameObject.DontDestroyOnLoad(gameObject);
music = GetComponent();
music.clip = startClip;
music.loop = false;
music.Play();
}
}
void OnLevelWasLoaded(int level){
Debug.Log("Music Player: loaded level " + level);
//music.Stop();
if (level == 0){
music.clip = startClip;
music.Play();
music.loop = false;
}
if (level == 1) {
music.clip = gameClip;
music.Play();
music.loop = true;
}
if (level == 2){
music.clip = loseClip;
music.Play();
music.loop = false;
}
if (level == 3){
music.clip = winClip;
music.Play();
music.loop = false;
}
}
}
My problem lies in that the bool I am tryin to access is in the FormationController script attached to the EnemyFormation object, which is in a different scene.
I tried accessing it by doing sth like this:
if (!GameObject.Find("EnemyFormation").GetComponent<FormationController>().isBossTime){
print ("Bool Works");
music.Stop();
music.clip = bossIntro;
music.Play();
music.loop = false;
music.clip = bossFight;
music.Play();
music.loop = true;
}
}
But unfortunately it doesn’t work