Question by
unity_W9W4Vi5PVTXe8A · Nov 24, 2020 at 06:53 PM ·
inputanimator
I want to active my animation when I press multiple buttons! HELP
Why my animation only work when i press "d" button?
this is my script!!
public class PlayerMovemnent : MonoBehaviour { public Transform player; public float speed = 5.0f; public Animator animator;
void Update()
{
//movement
float horizontal = Input.GetAxis("Horizontal");
transform.position += new Vector3(horizontal, 0, 0) * speed * Time.deltaTime;
//animation
if (Input.GetKey("d") || Input.GetKey("a"))
{
animator.SetBool("isWalking", true);
}
if (!Input.GetKey("d") && Input.GetKey("a"))
{
animator.SetBool("isWalking", false);
}
}
}
Comment