vendredi 19 juillet 2019

Why the code goes to else if the statement is true?

I am trying to spawn my obstacles with level improvement, but for some reason when i tested it in game it doesn't work how i want.

Lets say i start game from 26 level.

I play normally until the level 36, even the 35 level spawning correctly but when player reach level exactly on 36 the code goes into else statement not in else if..

This is my code to spawn obstacles by levels..

     if(curentLevel > 0  && curentLevel < 10)
    {
        SpawnSpawner(0);
    }else if(curentLevel> 10 && curentLevel < 35)
    {
        SpawnSpawner(1);


    }
    else if(curentLevel>35 && curentLevel < 50)
    {
        SpawnSpawner(2);
    }else if(curentLevel>50 && curentLevel < 60)
}else {

}

the code on in else statement gets executed which is empty in my example exactly on level 36.

I hope there is solution why because I told the program to check if curentlevel is higher then 35 which is on 36 level and if the level is smaller then 50 which is 36 , so I don't have idea why then its not executed this code:

 else if(curentLevel>35 && curentLevel < 50)

I bet I do something wrong but I hope someone will point me to solution and explain why program doesn't work on my way of thinking, thanks so much...

Aucun commentaire:

Enregistrer un commentaire