// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!GuardSound.Source().isPlaying) { GuardSound.Source().PlayOneShot(clips[Random.Range(0, clips.Length)]); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (clips.Length > 0) { GuardSound.Source().mute = false; GuardSound.Source().PlayOneShot(clips[Random.Range(0, clips.Length)]); } else { GuardSound.Source().mute = true; } }
public void Yell() { GuardSound.Source().PlayOneShot(clips[Random.Range(0, clips.Length)]); }