Hey, I want call OnStateEnter on a state but only if it transitioned from a specific state and not from all the states connected to it, how can this be done? I just want to call a function if a specific state is transitioning to another specific state, thanks.
So I came up with my own solution for now, if you have a better one post it as an answer and I’ll change it. What I ended up doing was getting the name hash every late update, so that I can check what state it was in the previous frame.
void LateUpdate()
{
previousStateHash = animState.shortNameHash;
}
And then any Behaviour scripts can check if the previous state was a state in particular by doing:
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if(previousStateHash == Animator.StringToHash("Some_State"))
Debug.Log("Transitioned from Some_State");
}