I’m trying to make it so that when my player reaches a new level, a sound effect will play representing the level up.
public AudioClip levelUpSound; // my public audioclip used for the code below
if (xp >= miningLevel * multiplier + baseXp)//this is basic formula which you can later edit to suit how fast player should advance
{
miningLevel++;
print("Congratulations You've Reached Level" + ":" + " " + miningLevel); //On level up print new level
xp = 0; // hard reset to 0
NewFeature(); //On certain levels up include new feature like new ore to mine
GetComponent<AudioSource>().Play();
}
This is what I’ve got right now and in the inspector I have dragged the audio clip into the correct slot. It just doesn’t play when the player levels up. Any ideas?