Problem with change the animation in blend tree from left to right

Every time that i go from left to the right the animation is not smooth, the animation change to Idle then go to right.


The animator make the change if “Walk”==true then change to walk, else change to Idle.
84800-animator.png


“X” and “Y” are the variables of the blend tree.84801-animator.png


The little Script that make the Character move.

// Use this for initialization
void Start () {
	rb=GetComponent<Rigidbody>();
	anim = GetComponent<Animator>();
}

// Update is called once per frame
void Update () {
	float moveX = Input.GetAxis ("Horizontal");
	float moveZ = Input.GetAxis ("Vertical");
	anim.SetFloat ("X", moveX);
	anim.SetFloat ("Y", moveZ);
	if (moveX != 0 || moveZ != 0) {
		rb.velocity = new Vector3 (moveX * speed * Time.deltaTime, rb.velocity.y, moveZ * speed * Time.deltaTime);
		anim.SetBool ("Walk", true);
	} else {
		anim.SetBool("Walk",false);
	}
}

PS: i know that i have to improve the movement script!

This a 4 years old answer, I know, but it might be helpful for someone having the same problem, as I did. I fixed it by going into the Project settings, then in the Input Manager, for the Vertial and Horizontal axis movements there’s an option called Snap. I unchecked it and the problem was solved.