Issue with getting a random animation using OnStateEnter

Hey there friends!
I’ll try to keep this concise. I am trying to create an “isTalking” Sub-State Machine to play random talking animations when an isTalking bool is activated. I have a Sub-State Machine with a bunch of animation clips that are all linked together with transitions. Using transition logic, they are all associated to a specific index of an integer parameter.

I am trying to use a script to randomize the index when the sub state machine is entered so it will pick a new random animation each time one is played.

The issue I’m running into is that it will always play the index [0] animation when isTalking is first entered, nomatter what number is randomly generated for the parameter. It appears as though the OnStateEnter method gets calculated after the StateMachine is already entered and a subsequent state has been picked.

Because of this, the random animation that is picked will always be an index generation behind.

Does this sound correct to folks? Is there a better way of doing this sort of thing?

Thanks