void Shoot() { if (GameManager.Instance.InputController.fire) { if (gun.Fire()) { soundTrigger.AddSound(soundTrigger.GetSoundRadius() * 3.5f + 1); muzzelFlash.Play(); fireTime = Time.time; RaycastHit hit; int layerMask = (1 << 9); //Zombie is on layer 9 if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, range, layerMask)) { Health target = hit.transform.GetComponent <Health>(); if (target != null) { target.TakeDamage(damage); } } } } if (Time.time - fireTime >= 0.1f) { muzzelFlash.Stop(); } }
// Triggered by the animator every time the player makes a footstep private void Step() { if (m_player.inputEnabled) { bool isRunning = m_animator.GetBool("IsRunning"); bool isCrouching = m_animator.GetBool("IsCrouch"); if (isRunning) { m_audioSource.volume = 1; m_soundTrigger.AddSound(10f); } else if (isCrouching) { m_audioSource.volume = 0.25f; m_soundTrigger.AddSound(2f); } else { m_audioSource.volume = 0.5f; m_soundTrigger.AddSound(5f); } m_audioSource.PlayOneShot(m_walkDirtClips[Random.Range(0, m_walkDirtClips.Length)]); } }