79346905

Date: 2025-01-10 20:11:02
Score: 0.5
Natty:
Report link

My code I just pass into the animator a bool for if the player is walking or not. And if the player is walking then I pass in the X and Y or its directions to the animator's floats X and Y which are used by the blend tree. I'm using two blend trees as you can see. One for idle and one for walking

Vector2 direction;
[SerializeField] float playerSpeed;
Animator animator;
private void Update()
{
    float horizontal = Input.GetAxis("Horizontal");
    float vertical = Input.GetAxis("Vertical");
    direction = new Vector2(horizontal, vertical).normalized * playerSpeed;

    animator.SetBool("Walking", direction != Vector2.zero);
    if (direction != Vector2.zero)
    {
        animator.SetFloat("X", horizontal);
        animator.SetFloat("Y", vertical);
    }

}

Base LEvel Blend Tree

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Mike The Elf