private void OnTriggerEnter(Collider other) { healthControler livingObject = other.GetComponent <healthControler>(); if (livingObject != null) { livingObject.takeDmg(bulletDmg); } if (hitSplash != null) { var newHitSplash = Instantiate(hitSplash, transform.position, Quaternion.identity); } if (other.transform.parent != null) { drop_consumable drop = other.transform.parent.GetComponent <drop_consumable>(); if (drop == null) { Destroy(gameObject); } } else { Destroy(gameObject); } }
void Awake() { rigidbody = GetComponent <Rigidbody> (); animator = GetComponent <Animator>(); gManager = GameObject.Find("GlobalManager").GetComponent <globalManager> (); playerHealthControler = GetComponent <healthControler> (); updateItems(); }
void gotHealth(GameObject player) { healthControler dude = player.GetComponent <healthControler>(); dude.health += healthStep; if (dude.health > dude.startHealth) { dude.health = dude.startHealth; } dude.updateBar(); Destroy(gameObject); }