I was making a very basic gun script, I don’t remember what I did to make it not work, heres the main code
Animator m_Animator;
public Rigidbody Bullet;
public Transform barrelEnd;
public float firerate = 0.5f;
// Start is called before the first frame update
void Start()
{
m_Animator = gameObject.GetComponent<Animator>();
StartCoroutine(SpawnLoop());
}
IEnumerator SpawnLoop()
{
while (enabled)
{
if (Input.GetButton("Fire1"))
{
Rigidbody rocketInstance;
rocketInstance = Instantiate(Bullet, barrelEnd.position, barrelEnd.rotation) as Rigidbody;
m_Animator.SetBool("shoot", true);
yield return new WaitForSeconds(firerate);
}
}
}
void FixedUpdate()
{
m_Animator.SetBool("shoot", false);
}
Sorry for the headaches.