public void OnStart() { barrel = GetComponentInChildren <BarrelBehaviour>(); if (barrel != null) { barrel.OnStart(); } mag = GetComponentInChildren <MagBehaviour>(); if (mag != null) { mag.OnStart(); } if (mag != null && barrel != null) { mag.SetupAmmo(barrel.GetBarrelEnd()); if (barrel.muzzle != null) { (mag.Ammo as Projectile).audioSource.pitch = barrel.muzzle.data.GetStats(WeaponPartStats.Pitch, 1f); (mag.Ammo as Projectile).audioSource.volume = barrel.muzzle.data.GetStats(WeaponPartStats.Volume, 1f); } } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Barrel") { Debug.Log("In water"); BarrelBehaviour barrel = collision.gameObject.GetComponent <BarrelBehaviour>(); barrel.OnGetIntoWater(); barrel.GoUp(); } }