private void OnTriggerEnter(Collider other) { Shotgun2 Shotgun = shotgun.GetComponent <Shotgun2>(); if (other.CompareTag("Player") && isTriggerPickup && Shotgun.currentShells != Shotgun.maxShells) { TakeAmmo(); AudioSource.PlayClipAtPoint(pickup, transform.position, volume); } }
void TakeAmmo() { Shotgun2 Shotgun = shotgun.GetComponent <Shotgun2>(); Shotgun.currentShells += quantity; if (Shotgun.currentShells > Shotgun.maxShells) { Shotgun.currentShells = Shotgun.maxShells; } Shotgun.SetUI(); Destroy(gameObject); }