Esempio n. 1
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        _timer += Time.deltaTime;
        if (_timer >= _individualAnimationLength)
        {
            float previousValue = _values[_currentAnimationIndex];

            _timer = 0f;
            _currentAnimationIndex++;
            if (_currentAnimationIndex >= _values.Count)
            {
                _currentAnimationIndex = 0;
            }

            if (_stateMachine != null)
            {
                _stateMachine.StartChangeAnimationCoroutine(_values[_currentAnimationIndex], animator, previousValue, _parameter);
            }

            animator.SetFloat(_parameter, _values[_currentAnimationIndex]);
        }
    }