- Home /
Checking an increasing number
Hi, I have the following problem.
I have this float, which im increasing by checking when a certain condition is false. Then I check whether a certain treshold is met.
The increasing part works, but when the float passes the treshold, here 25, nothing happens. When I set the float manually to a number above the treshold, the function works as expected.
I'm probably missing something really stupid, any insights on this?
regards, Rob
 float car1flipped = 1;
     float car2flipped = 1;
 
 void Update () {
     
     GameObject car1 = GameObject.FindWithTag("Bottom1");
     GameObject car2 = GameObject.FindWithTag("Bottom2");
     
     if (car1 == null)
             Debug.Log("Car1 is not found");
     
     if (car2 == null)
             Debug.Log("Car2 is not found");
         
     VehicleBottom1 sc1 = car1.GetComponent<VehicleBottom1>();
     VehicleBottom2 sc2 = car2.GetComponent<VehicleBottom2>();
         
         Debug.Log (car1flipped);
         Debug.Log (car2flipped);
         
         if (sc1.touchingGround == true)
             car1flipped += (1 * Time.deltaTime);
     
         
         if (sc2.touchingGround == true)
             car1flipped += (1 * Time.deltaTime);
         
             
         
         if(car1flipped >= 25 && car2flipped >= 25)
         Application.LoadLevel ("Drawscreen");
         
 
     
     }
Answer by robertbu · Jul 04, 2013 at 07:32 PM
Your bug is on line 26. You are checking sc2, but you are incrementing 'car1flipped'. You should be incrementing 'car2flipped'.
Your answer
 
 
             Follow this Question
Related Questions
int myX = (int)transform.position.x; 1 Answer
Rounded particle motion 0 Answers
Floating Point and ToString issue 2 Answers
Why aren't these numbers going down by 1. 1 Answer
GUI.HorizontalSlider precision 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                