Trouble with background music and listeners.

First off, I am a beginner; I’ve only started using Unity 2 days ago so I’m not familiar with a lot of Unity has to over yet.

Anyway, I’m trying to make a game where:

  1. The audio from the first scene follows my player through each scene and
  2. on one scene there is a song that progressively gets louder but it isn’t the same scene the first song is started in.

What I have right now is a Camera that has the first Audio Source and the camera doesn’t get destroyed upon changing scenes. Now, I know this is where something weird is happening but I can’t figure out what. I have a new camera on each scene that follows the player because I can’t get the first camera to track the newly spawned player. This camera has no audio listener. The problem with keeping the same player is getting it to spawn on the right coordinates in the next scene. Because of this, it seems the one camera stays in the same spot and doesn’t follow the player to the area with the new music.

My ideal situation would be for the camera and player to go to every scene, in the spot I want them to, and then have the listener on the camera pick up all the sound it can, which it should if it follows the player. Can someone please help me figure out what to do to get it to work the right way?

Any GameObject and its children can be preserved between scenes by using:

DontDestroyOnLoad(this);

Your character can at any time have its position changed to anything, you could simply create Spawn Location gameobjects, place one in each scene and upon load tell the character go-to-there with something like:

transform.position = GameObject.Find("SpawnLocation").transform.position;

The camera can be a child of the character or a flying camera trying to keep a certain distance and orientation relative to the character, in that case it would have something like Transform target in a script and would move according to the target with Update or FixedUpdate, depending on whether or not the camera is a rigibody. If it is a dynamic camera that gets left behind, it could simply have code that says “as soon as I’m too far away, I’ll appear right behind that bastard!”. That would also handle the camera getting stuck.