dimanche 3 décembre 2017

If-else statement for changing levels

I have a got a function for changing levels in my game. In the game, the first level changes to the second level correctly. But the second level changes to the first level too. How can I fix this? Here is my code:

public void CheckLevelCompletion() {
    if ((count == 4) && (levelOneCompleted == false)) {
        img.sprite = levelCompletedImage;
        count = 0;
        levelOneCompleted = true;
        SceneManager.LoadScene("FifthGameSecondLevel");
    }
    else if ((count == 6) && (levelOneCompleted == true))
    {
        img.sprite = levelCompletedImage;
        count = 0;
        levelTwoCompleted = true;
        SceneManager.LoadScene("FifthGameThirdLevel");
    }
} 

Aucun commentaire:

Enregistrer un commentaire