private TPCharacter character = null; // game character reference /// <summary> /// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state /// </summary> /// <param name="animator"></param> /// <param name="stateInfo"></param> /// <param name="layerIndex"></param> override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (character == null) { character = animator.transform.GetComponent <TPCharacter>(); } if (character != null) { character.turnToDiveRollDIrection(); } }