Hi. I have a doubt : could we also use Coroutines to make the enemy shoot ? For example I have added the following coroutine in my project. Is it ok ?
void Start()
{
StartCoroutine(Shoot(laserPrefab));
shotCounter = UnityEngine.Random.Range(minTimeBetweenShots,maxTimeBetweenShots);
}
IEnumerator Shoot(GameObject laserPrefab)
{
while(true)
{
GameObject laser = Instantiate(laserPrefab, transform.position, Quaternion.identity);
laser.GetComponent<Rigidbody2D>().velocity = new Vector2(0, -projectileSpeed);
yield return new WaitForSeconds(shotCounter);
shotCounter = UnityEngine.Random.Range(minTimeBetweenShots,maxTimeBetweenShots);
}
}
And if my method is right, why didn’t you use coroutine ? BY the way my methdo is working just fine