English 中文(简体)
统一估算过渡
原标题:Unity Animation Transitions

我有一份单独的文字,处理我的参与者的估算;在文字中没有任何问题。 我知道的理由是,它为我的参与者行走、跳跃和 c。 然而,当参与者把左 mo点击到攻击时,便会出现问题。 它向二分之一过渡,然后恢复参与者的步行、闲.、跳跃或 c。 在参与者的投入职能中,我有一个包裹,如果我发动攻击,就可以检查。 除此之外,我还有一项“授权”职能,使我的《行动图》能够为参与者提供投入。

        // Player Input
        private void CheckCombatInput(InputAction.CallbackContext context)
        {
            if (context.performed)
                isAttacking = true;
        }

        // Player Move 
        public void PlayerMove()
        {
            bool isWalking = false;
            if (isFacingRight && horizontal < 0)
            {
                Flip();
            }
            else if (!isFacingRight && horizontal > 0)
            {
                Flip();
            }

            moveSpeed = playerMovementForce * Time.fixedDeltaTime;
            if (isCrouching)
            {
                moveSpeed *= crouchSpeedMultiplier;
            }

            rb.velocity = new Vector2(horizontal * moveSpeed, rb.velocity.y);
            if (isGrounded && !jump && !isCrouching && !isAttacking)
            {
                isWalking = Mathf.Abs(horizontal) > 0;
                PlayerAnimator.Instance.ChangeAnimationState(isWalking ? PlayerAnimator.Player_Walk                               :               PlayerAnimator.Player_Idle);
            }
        }

        // Player Attack
        private void PlayerAttacks()
        {
            if (isAttacking)
            {
                canFlip = false;
                PlayerAnimator.Instance.ChangeAnimationState(PlayerAnimator.Player_Attack);
                isAttacking = false;
            }
            else
            {
                canFlip = true;
                isAttacking = false;
            }
        }

我试图制造一个有限的国家机器,现在我仍然难以执行。

问题回答

我认为,为了解决这个问题,你可以尝试在你的文字中采取以下步骤:

  1. Delay Resetting isAttacking: Move isAttacking = false; to the end of the attack animation instead of immediately after setting the attack state. This can be done using an Animation Event. (I will explain with details if you need with comment)
  2. Check Animator Transitions: Please ensure that Animator transitions from the attack animation back to other states(like idle or walk) don t happen too quickly. Adjust the conditions and exit times in the Animator to allow the full attack animation to play.
  3. Use Animation Layers: Place the attack animation on a separate layer in the Animator and set its priority higher. This allows the attack animation to play fully even if other animations are triggered.

为此,希望会取得良好结果。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签