State Machine Transitions Stop Loop after Exit State

Hi, i have a question on state machine.

Im creating a tutorial scene, where i animate hand pointer image to teach player how to play the game.

below is how i designed the state machine.

56167-handanimator.png

basically Run Up State, is just an animation that doesnt move the hand pointer but just remain in same position for 0.15 sec.

Problem that im facing right now is, after i finish run the TutVerticalSwipe (animate hand pointer to move vertically)

it will transition to Run Up state (animate hand pointer to be at start point)

it keeps looping the state from Run Up → TutVerticalSwipe → Run Up for three times

even though in my code. in OnExitState method , (im using StateBehaviour for each state)
i already set animator.SetBool(“TutVerticalSwipe”, false);

i just want the Run Up ->TutVerticalSwipe → Run Up to run Once not three times.

The state machine behaviour’s OnStateExit method fires when the state is completely exited. This does not play well with transition times, as the next state starts being handled before that - sometime during the transition.

Generally, avoid setting variables from within the animator on the state before those variables will be used - it’s just not reliable. Don’t let the name “state machine behaviour” fool you - these are not real state machines, as two states can and will be active at the same time.

In your case, the best design would just to use a trigger instead of a bool, or to set the bool outside of the state machine entirely.