- Home /
Question by
vverma9 · Mar 26, 2019 at 08:40 AM ·
animationstatestate-machinestate machine
Unity OnStateExit StateMachineBehaviour is never getting called
I have a script attached to my Animation state as shown below:
The script is as follows:
using UnityEngine;
public class TrackHelpDuration : StateMachineBehaviour {
// 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) {
Debug.Log("entering state");
if (GameSession.timeSpentOnRemedialHint > 0)
GameSession.updateTime(11);
}
// 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) {
Debug.Log("exiting state");
if (GameSession.timeSpentOnRemedialHint > 0)
GameSession.updateTime(11);
}
}
While OnStateEnter
is working as expected, OnStateExit
is never getting called. How do I make it work?
Comment
Your answer
Follow this Question
Related Questions
Easier way of creating transitions in the animator? 1 Answer
Can an empty state in Animator cause performance issues? 1 Answer
How to delete a StateMachineBehaviour via Editor Script? 1 Answer
Switch animation state while keeping animation timing 0 Answers
How do I make the transition between two states in the "Animator" happen instantly? 3 Answers