- Home /
need help, with greater than statment
i need help to write a greater than statmentm this what i have
     void OnMouseDown () 
     { 
                 if (NivelActual > estadoJuego.puntuacionMaxima) {
                         Destroy (Camara);
                         Application.LoadLevel (nivelScene);
                 }
         }
and, NivelActual = 9 , estadoJuego.puntuacionMaxima = 7
but the script starts anyways, and if i put
     void OnMouseDown () 
     { 
                 if (1 > 5) {
                         Destroy (Camara);
                         Application.LoadLevel (nivelScene);
                 }
         }
it just ignore it...
thank you!
anyways, if i put
      void On$$anonymous$$ouseDown () 
      { 
                  if (1 > 5) {
                          Destroy (Camara);
                          Application.LoadLevel (nivelScene);
                  }
          }
the code just starts...
On$$anonymous$$ouseDown does something different to what you are expecting. In the second codeblock if (1 > 5) guarantees it wont execute. When is 1 bigger than 5? 
Oh, hang on a $$anonymous$$ute! NivelActual = 9 , estadoJuego.puntuacion$$anonymous$$axima = 7, and the statement if (NivelActual > estadoJuego.puntuacion$$anonymous$$axima) "runs anyway". Well that's completely expected. 9 is bigger than 7! 
yes, EstadoJuego its static. okay, i make this:
 void On$$anonymous$$ouseDown () 
 { 
     if (1 > 5) {        
                     Debug.Log ("hola");
                     Destroy (Camara);
                     Application.LoadLevel (nivelScene);
             } else {
             
         Debug.Log ("chau");
     }
}
on the debug, i can see the "chau" message, but the scene changes anyway....
Answer by idurvesh · Jan 11, 2015 at 12:41 PM
Its because u stating that
  if(1 is greater than 5) { then execute this}
but 1 is less than 5 so script ignores it.
make it like if(5>1){//this will run}
In first case 9 is greater than 7 , so its getting executed.
Your answer
 
 
             Follow this Question
Related Questions
Ending my game 3 Answers
Cannot fix error anyone have any suggestions 1 Answer
Error BCE0018 0 Answers
Need Help Understanding Script! (Javascript) 1 Answer
Error in script 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                