Change the sound during the game


(DAVID CLADERA) #1

Hi i try to change the music during the game, cheking the health of my player.

I use this script.

void Update ()
{
// If the player has run out of health…

		// controlamos la salud del jugador, para saber cuando esta a ZERO, y entonces paramos la música o activamos una segunda
		if(playerHealth.currentHealth <= 60) 
{
		// ... tell the animator the game is over.
		//Debug.Log ("jajajajaja stooooooop");
			FondoMusica.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
			//paramos nuestra musica
		
	}

		if (playerHealth.currentHealth <= 40) {
			Musicamorting.start ();
		}
	

}

the first music start at the beginning of the game, and stop perfectly when the health arrives to 60.
Then the second music not start at 40, start when the game start again, and at the same time with the first music.

Could someone help me?

thanks


(Cameron Baron) #2

I cannot tell much from that snippet but that should work to play an event, just double check it has been initialized/created before trying to play it.