void PlayGunSound() { //Play gun sound if (gunSounds != null) { // Debug.Log("Player gun sound"); gunSounds.PlayOnce(); } }
void OnTriggerEnter(Collider other) { //Retreive damageable Damageable dmg = other.GetComponent <Damageable>(); //Exit if nothing hit if (dmg == null) { return; } //Prevent self harm if (dmg.gameObject == m_owner) { return; } //Bounce of an object that is not on target layer if ((targetLayers.value & (1 << other.gameObject.layer)) == 0) { return; } //Do the damage! dmg.TakeDamage(damage); //Play a sound if (impactSounds != null) { impactSounds.PlayOnce(); } //Particles! if (hitParticle != null) { hitParticle.Play(); } //Clean up (gun is responsible for destroying object) if (destroyOnContact) { Destroy(gameObject); } }
//------- Accessible via unity events ------/ private void PlayHitSound() { hitSounds.PlayOnce(); }