Walking animation continues when player is stopped. Animator transition set to Idle at 0 Speed

Hey All,

Fairly new to unity and animation in general. I’m tyring to make an 8 directional player controller similar to Enter the Gungeon where the player object rotates and displays the idle sprite and walking animations based on the location of the mouse (Animation is triggered by movement but the direction of the movement does not change the direction the player is facing)

Im trying to get my character to transition between idle states when he is not moving but the mouse is, and change to walking animations when he and the mouse are both moving.

Im running into an issue where certain walking animations dont switch to idle when the player stops even though Ive set a transition to move to idle when his speed is 0.

Attached is a gif of the issue. The walking animation continues until my mouse hits the relative “1” value on the horizontal axis. The same thing happens for vertical.

Below is the blend tree setup to detect my mouse position to transition between the 8 directions. This works fine for movement and only causes an issue when I stop (Only using 4 directional idle sprites)

Here is an example of the transition I have setup to move to idle. Please excuse what I can only imagine is a messy animator.

Here is my player controller script. Any advice would be greatly appreciated!

public class Player2Movement : MonoBehaviour
{
    public float moveSpeed = 5f;
    public Rigidbody2D rb;
    public Camera cam;
    public Animator animator;
    Vector2 movement;
    Vector2 mousePos;
    Vector2 posDif;


    void Update()
    {
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");
        mousePos = cam.ScreenToWorldPoint(Input.mousePosition);

        posDif = mousePos - rb.position;

        animator.SetFloat("Horizontal", posDif.x);
        animator.SetFloat("Vertical", posDif.y);
        //animator.SetFloat("Horizontal", movement.x);
        //animator.SetFloat("Vertical", movement.y);
        animator.SetFloat("Speed", movement.sqrMagnitude);
    }

    void FixedUpdate()
    {
        rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
    }
}

6166002--674523--WalkingGif.gif

I fixed my issue!

No changes to code, I just dont know how to use blend trees properly like a doof. Fix was simple deleting all of the unnecessary transitions between the different idle states and to set up a blend tree under one idle state and set it to the same location parameters as the movement tree but active on a speed of “Less than 0.01”

And here is the idle blend tree

If anyone comes across this and has any recommendations on how to do it better I would love the CC. that said though it did fix my issue.

I do have a very small problem of my walking animation not getting interrupted by transitioning to the idle state (Player takes an extra ‘step’ before transitioning to idle). I’ve turned off all exit times and set the movement tree to be able to be interrupted by the idle state but there is still a very slight transition frame so to speak.