In the below code once the player finishes the level it reloads the level with the level being +1 from before. I used brackeys code here for the save/load: SAVE & LOAD SYSTEM in Unity - YouTube
The script is definatley only firing once, I have made sure of that as well. The debug.log shows that it fires twice and I have no idea why, any help is appreciated, thanks.
`
public class isLevelDone : MonoBehaviour
{
public GameObject player;
void Start()
{
PlayerData data = SaveSystem.LoadPlayer();
player.GetComponent<Player>().level = data.level;
}
void Update()
{
if (SpawnPitHoles.orcsDead && CollisionShield.arrowsDone)
{
endLevel();
}
}
public void endLevel()
{
SpawnPitHoles.orcsDead = false;
CollisionShield.arrowsDone = false;
player.GetComponent<Player>().level++;
SaveSystem.SavePlayer(player.GetComponent<Player>());
Debug.Log("Level Complete" + " player level is " + player.GetComponent<Player>().level);
Application.LoadLevel(Application.loadedLevel);
}
`