Im trying to recognize joystick movement and then switching unity animations based on it.
How can i do this? I have set the bool parameter “isWalking” correctly into animator with transactions.
// Update is called once per frame
void Update()
{
if (Input.GetKey(""){ // IN HERE I AM SUPPOSED TO CONNECT TO JOYSTICK MOVEMENT
anim.SetBool("isWalking", true);
}
else
{
anim.SetBool("isWalking", false);
}
}
Try using GetAxis instead of getkey. because as far as i know getkey is for getting keyboard input and you have to use keycodes. getaxis is much better since its checking for a lot of input types and highly configurable.
you need to use it like this however;
if (Input.GetAxis("Horizontal") > 1)
//right
else if (Input.GetAxis("Horizontal") < 1)
//left
//or
if(Input.GetAxis("Horizontal") != 0)
//move left right
if (Input.GetAxis("Horizontal") > 1 ){
anim.SetBool("isMoving", true);
}
else if (Input.GetAxis("Horizontal") < 1)
{
anim.SetBool("isMoving", false);
}
}
}
Still no animation changing from idle → walk…
i have set bool parameter from animator with transactions , bool isMoving true → goes to walk animation, and if bool is false → goes back to idle…
Any ideas ?