Blend tree finished too fast

When blend tree jump is running, it is interrupted by hit animation. Then, blend tree jump has not finished yet but jumped to movement tree even though trigger on ground is not set. How can i fix this? Here is my code and video:

private void SetAnimationType()
    {
        // If player is deaded
        if (playerDamageReceiver.IsDead || playerDamageReceiver.IsBeingHit) return;
        
        // Set animation animation style depend on current character statesF
        if (!playerMovement.IsGrounded && !isJumping)
        {
            animator.SetTrigger(PlayerString.PlayerAnimationParameters.IS_JUMPING);
            isJumping = true;

            // Play sound
            SoundFXManager.Instance.PlaySound(AudioString.SoundString.JUMP);
        }

        if (playerMovement.IsGrounded && isJumping)
        {
            animator.SetTrigger(PlayerString.PlayerAnimationParameters.IS_GROUND);
            isJumping = false;
        }

        animator.SetFloat(PlayerString.PlayerAnimationParameters.MOVE_X,
        Mathf.Abs(playerRb2D.velocity.x));

        animator.SetFloat(PlayerString.PlayerAnimationParameters.MOVE_Y,
        playerRb2D.velocity.y);
    }

My error video

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

2 Likes

You can add a condition to the transition from the hit animation back to the movement tree, ensuring that IsGrounded is set to true before allowing it to transition to movement.

1 Like