#Transitions happen before OnStateEnter() called?

1 messages · Page 1 of 1 (latest)

hearty ingot
#

I'm trying to have an animation behavior script select a random int on the interval [0,2], and set a parameter to that random number. That works as intended. However, these animation transitions seem to not register that parameter change, and instead use the index that was selected the previous time

#

here's the transition to the state

#

...the behavior attached to the attack state

#
    public AnimationCurve[] punchVelocity;
    float _timer = 0;
    int _punchType;
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        _timer = 0;
        _punchType = Random.Range(0, 3);
        animator.SetInteger("PunchType", _punchType );
        manager = animator.GetComponent<GruntManager>();
        if (manager)
        {
            if (_punchType == 2) manager.SetTurnSpeed(0);
            else manager.ResetTurnSpeed();
        }
        animator.SetBool("IsAttacking", true);
    }
    override public void OnStateMachineExit(Animator animator, int stateMachinePathHash)
    {
         animator.SetBool("IsAttacking", false);
}
``` relevant c# code
#

these 3 animations are played depending on what index was randomly selected