What I am trying to do is make it so when you open the game im making it will start playing a song, and then when I go through the menu and other screens it still plays, But I also want it to play when you go into the actual game.
Ive attempted 2 ways of putting in the music but neither really seem to work, The first way Ive attempted was to put an audio source on the camera, but when I put “DontDestroyOnLoad” it just doesnt play the music. I also use different cameras for the Menu and Game.
The second way I attempted was for it to generate the music prefab, and that one keeps playing the song how I want, but when I play the game it says this:
And when I try to pause the game it just doesn’t stop the background music as its not attached to the main camera.
This is the Code I have for the second method to generate the music:
#pragma strict
var music : GameObject;
function Start () {
var G : GameObject = GameObject.FindGameObjectWithTag("GameController");
if(!G){
Instantiate(music, Vector3.zero, Quaternion.identity);
}
}
So I have no idea on how I would go about make that be attached to the main camera like it wants me to.
So any help on either of those methods would be extremely useful!