Hi everyone !
So i have 2 scripts which i want to bassicly do this : Have the same audio as in the main menu(my main menu has 4 scenes) and a different ambient sound in the actual game itself. My first scripted ,i attached to an empty game object called Music and added the tag : GameController. i attached this script to it
var Clip1 : AudioClip;
var Clip2 : AudioClip;
function Start () {
DontDestroyOnLoad(gameObject);
if(Application.loadedLevel == “0”){
audio.clip = Clip1;
} else if(Application.loadedLevel == “5”){
audio.clip = Clip2;
}
}
i attached my second script to the main camera this is the script :
var music : GameObject;
function Start(){
var G : GameObject = GameObject.FindGameObjectWithTag(“GameController”);
if(!G){ Instantiate(music, Vector3.zero, Quaternion.identity);
}
}
When i run the game unity doesn’t give me any error ,but it doesn’t work for some reason
Could anyone please help me?