Пример #1
0
        private void Update()
        {
            if (attack)
            {
                animator.SetFloat(Vertical, 0f);
                animator.SetFloat(Horizontal, 0f);
                return;
            }

            if (Mathf.Abs(input.Vertical) > 0)
            {
                animator.SetFloat(Vertical, input.Vertical);
                animator.SetFloat(Horizontal, 0f);
                facing = input.Vertical < 0 ? 1 : 2;
                OnFacingChange?.Invoke(facing);
            }
            else if (Mathf.Abs(input.Horizontal) > 0)
            {
                animator.SetFloat(Horizontal, input.Horizontal);
                animator.SetFloat(Vertical, 0f);
                facing = input.Horizontal < 0 ? 3 : 4;
                OnFacingChange?.Invoke(facing);
            }
            else
            {
                animator.SetFloat(Vertical, 0f);
                animator.SetFloat(Horizontal, 0f);
            }

            animator.SetInteger(Facing, facing);
        }