I have created a script so that my animation starts when I press ‘d’ and stops when I let go. But then it won’t start again (when I press d).
using UnityEngine;
public class animation_hero : MonoBehaviour
{
public GameObject hero;
void Update()
{
if (Input.GetKey(“d”))
{
hero.GetComponent().Play(“animation”);
}
if (Input.GetKeyUp(“d”))
{
hero.GetComponent().enabled = false;
}
}
}