How can I make the ‘if’ statement look to see if another animation is not running?
This is the code:
[SerializeField] private float speed;
[SerializeField] public float jumpPower;
private Rigidbody2D body;
private Animator anim;
private void Awake()
{
//Grab reference for rigidbody and animator from object
body = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
private void Update()
{
//Move player
transform.position = Vector3.right * speed * Time.deltaTime + transform.position;
if(!anim)
{
anim.SetTrigger("Run");
}
if(Input.GetKeyDown("space"))
{
body.velocity = Vector3.up * jumpPower;
anim.SetTrigger("Jump");
}
}