Question by
Decrofts · Dec 27, 2016 at 02:21 PM ·
animationanimatoranimator controller
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.
"X" and "Y" are the variables of the blend tree.
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!
animator.png
(24.3 kB)
animator.png
(33.1 kB)
Comment
Answer by fmonroy · Jun 01, 2020 at 09:01 AM
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.