Still doing Running Animation?

So I’m stuck trying to make a movement script for my character and I’m trying to make the sprinting part of it and it does some weird things. When I press “W” is does the walking animation just fine and it kind of doesn’t automatically go into and out of the sprint animation but that is probably just an animation problem and I can fix it later. The problem lies when I try to come out of the sprint, when I am holding down “W” and “Left Shift” it sprints but if I let go of “W” but still hold “Left Shift” the animation still plays and even after I let go of “Left Shift”. Here is the code:

public class Movement : MonoBehaviour {

	static Animator anim;
	public float speed = 2.0f;
    public float rotationSpeed = 75.0f;
    public float runSpeed = 6.0f;

	void Start () {
        anim = GetComponent<Animator>();
	}

	void Update () {
        //Vertical Movements
		float translation = Input.GetAxis("Vertical") * speed;
        float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
		translation *= Time.deltaTime;
        rotation *= Time.deltaTime;

		transform.Translate(0, 0, translation);
        transform.Rotate(0, rotation, 0);

		if(translation > 0) {
			anim.SetBool("Forward", true);
            anim.SetBool("isMove", true);
		}

        if(translation == 0) {
			anim.SetBool("Forward", false);
            anim.SetBool("isMove", false);
        }

        if(translation < 0) {
            anim.SetBool("Forward", false);
            anim.SetBool("isMove", true);
        }

        //Running
        if(Input.GetKey(KeyCode.LeftShift) && anim.GetBool("isMove") == true) {
            
            //Speed Controller
            speed = runSpeed;

            //Animations
            anim.SetBool("Forward", true);
            anim.SetBool("isRun", true);
        } else {

            //Walking Speed
            speed = 2.0f;

            //Animation return
            anim.SetBool("isRun", false);
        }
	}
}

Use Input.GetKey(KeyCode.W), Input.GetKey(KeyCode.A), Input.GetKey(KeyCode.S), Input.GetKey(KeyCode.D) instead of the Axis.
The axis does not return to 0 immediately after you release W

But i noticed some problems too

  1. anim.GetBool(“isMove”) why do you access the bool from the animator. translation != 0 is the same thing but its alot faster.
  2. for these: “isRun”, “Forward”, “isMove”. Use constants!

Try this

public class Movement : MonoBehaviour
{
    public const string cstMove = "isMove";
    public const string cstForward = "Forward";
    public const string cstRunning = "isRun";

    static Animator anim;
    public float currentSpeed = 2.0f;
    public float rotationSpeed = 75.0f;
    public float walkSpeed = 2.0f;
    public float runSpeed = 6.0f;

    void Start()
    {
        anim = GetComponent<Animator>();
    }

    void Update()
    {
        float translation = 0;
        float rotation = 0;
        if (Input.GetKey(KeyCode.W))
        {
            translation = 1;
        }
        else if (Input.GetKey(KeyCode.S))
        {
            translation = -1;
        }

        if (Input.GetKey(KeyCode.A))
        {
            rotation = -1;
        }
        else if (Input.GetKey(KeyCode.D))
        {
            rotation = 1;
        }

        if (translation != 0 && Input.GetKey(KeyCode.LeftShift))
        {
            currentSpeed = runSpeed;
        }
        else
        {
            currentSpeed = walkSpeed;
        }

        transform.Translate(0, 0, translation * currentSpeed * Time.deltaTime);
        transform.Rotate(0, rotation * rotationSpeed * Time.deltaTime, 0);

        if (translation != 0)
        {
            anim.SetBool(cstMove, true);
            anim.SetBool(cstForward, translation > 0);
            anim.SetBool(cstRunning, translation > 0 && currentSpeed == runSpeed);
        }
        else
        {
            anim.SetBool(cstMove, true);
            anim.SetBool(cstForward, false);
        }
    }
}