32 lines
730 B
C#
Raw Normal View History

2025-09-06 17:17:39 +04:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Thomas09
[RequireComponent(typeof(AudioSource))]
public class NPCFootsteps : MonoBehaviour
{
private AudioSource audioSource;
private Animator anim;
void Awake()
{
audioSource = GetComponent<AudioSource>();
anim = GetComponent<Animator>();
}
private void PlayFootstep() //used in animation event
{
float randPitch = Random.Range(0.85f, 1.2f);
audioSource.pitch = randPitch;
audioSource.PlayOneShot(audioSource.clip);
}
private void ResetTriggers() //used in animation event.
{
anim.ResetTrigger("HeadHit");
anim.ResetTrigger("BodyHit");
}
}