This repository has been archived on 2025-03-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mojo-kitchen-chaos/Assets/Scripts/PlayerSounds.cs
2023-03-03 05:10:23 +11:00

32 lines
676 B
C#

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