Hey all,
Trying to set up a simple system that looks like this:
Animator Starts → Animator goes to SubState “idle” → A script fires to choose 1 of 6 random states → That state plays and loops.
Here’s what happens: Everything works, the script chooses the correct random state, but the Animator ignores my transition preferences and instead ALWAYS plays the default state that comes from Entry. What’s the solution here?
Animator:
Sample Transition:
if(stateIndex > x)…
OverrideCode:
public class randomSubStateManager : StateMachineBehaviour {
public int numStates;
// 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) {
int randoState = Random.Range(0, numStates);
Debug.Log("controller chose rando index: " + randoState);
animator.SetInteger("stateIndex", randoState);
}


