Advertisement
Wolvenspud

EW - wallScript

Nov 5th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class wallScipt : MonoBehaviour {
  5.  
  6.     public int hp = 15;
  7.     float damageTick = 0f;
  8.     public float damageInter = 0.4f;
  9.     public GameObject self;
  10.     public GameObject theUnitM;
  11.  
  12.     public void OnTriggerStay(Collider other)
  13.     {
  14.         if (other.tag == "emu")
  15.         {
  16.             damageTick += Time.deltaTime;
  17.             if (damageTick > damageInter)
  18.             {
  19.                 hp -= 1;
  20.                 if (hp < 1)
  21.                 {
  22.                     other.GetComponent<emuScript>().Move();
  23.                     theUnitM.GetComponent<unitManager>().UpdateGrid(self.transform.position);
  24.                     Destroy(self);
  25.                 }
  26.                 damageTick = 0f;
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement