Beispiel #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player" || other.gameObject.tag == "MainPlayer") //destroys train when its either
     {
         if (other.gameObject.tag == "MainPlayer")                                 //BUG: runs through this code twice and add 2 to the score instead of just 1
         {
             train = (TrainController)other.gameObject.GetComponent(typeof(TrainController));
             redGlow.SetActive(true);
             if (train.getHealth() >= train.getMaxHealth())
             {
                 redGlow.SetActive(false);
                 greenGlow.SetActive(true);
             }
         }
     }
 }
Beispiel #2
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (train)
     {
         num++;
         if (num > 25)
         {
             num = 0;
             train.heal(1);
         }
         if (train.getHealth() >= train.getMaxHealth())
         {
             redGlow.SetActive(false);
             greenGlow.SetActive(true);
         }
     }
 }