Add SFX and SFX logic
This commit is contained in:
parent
f0e4f6c9ba
commit
1aa97baff4
19 changed files with 504 additions and 8 deletions
32
Assets/Scripts/PlayerSounds.cs
Normal file
32
Assets/Scripts/PlayerSounds.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue