32 lines
730 B
C#
32 lines
730 B
C#
|
|
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");
|
|||
|
|
}
|
|||
|
|
}
|