void OnTriggerEnter(Collider other) { if (other.tag == "Ammo Bonus") { PlayerShooting playerShooting = GetComponentInChildren <PlayerShooting>(); AmmoBonus ammoBonus = other.GetComponent <AmmoBonus>(); playerShooting.AddAmmo(ammoBonus.ammoAmount); ammoBonus.DestroyBonus(); } }
public void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Ammo")) { if (playerShooting.AddAmmo()) { Destroy(other.gameObject); } } else if (other.gameObject.CompareTag("Health")) { if (playerHealth.AddHealth(other.gameObject.GetComponent <Health>().value)) { Destroy(other.gameObject); } } }