-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathResetState.cs
More file actions
31 lines (25 loc) · 813 Bytes
/
ResetState.cs
File metadata and controls
31 lines (25 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResetState : StateMachineBehaviour {
public string StateToReset;
public bool OnEnter;
// 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(OnEnter)
{
SwitchOff(animator);
}
}
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
if(!OnEnter)
{
SwitchOff(animator);
}
}
void SwitchOff(Animator animator)
{
animator.SetBool(StateToReset, false);
}
}