Exemplo n.º 1
0
    // OnStateMachineExit is called when exiting a state machine via its Exit Node
    public override void OnStateMachineExit(Animator animator, int stateMachinePathHash)
    {
        var transform = animator.transform;

        transform.localPosition = Vector3.zero;
        transform.localRotation = Quaternion.identity;
        OnIdleAnimation?.Invoke(animator, false);
    }
Exemplo n.º 2
0
    // OnStateMachineEnter is called when entering a state machine via its Entry Node
    public override void OnStateMachineEnter(Animator animator, int stateMachinePathHash)
    {
        var animationIndex = Random.Range(0, 6);

        if (animationIndex == _lastAnimation)
        {
            animationIndex++;
            if (animationIndex >= 5)
            {
                animationIndex = 0;
            }
        }

        animator.SetInteger(AlternateIdle, animationIndex);

        _lastAnimation = animationIndex;
        OnIdleAnimation?.Invoke(animator, true);
    }