KitchenChaos/Assets/Scripts/PlayerSounds.cs

20 lines
567 B
C#

using System;
using UnityEngine;
public class PlayerSounds : MonoBehaviour {
private Player player;
private float footstepTimer;
private const float footstepTimerMax = .2f;
private void Awake() => player = GetComponent<Player>();
private void Update() {
footstepTimer -= Time.deltaTime;
if (footstepTimer > 0f) return;
footstepTimer = footstepTimerMax;
if (!player.IsWalking()) return;
const float volume = 1f;
SoundManager.Instance.PlayFootstepsSound(player.transform.position, volume);
}
}