I found the approach of using StopCoroutine from the update() method to stop the firing a little weird. Generally I would hope that the Coroutine could be as self-sufficient as possible. So given we already have a while loop around the whole firing block, I did the following, and it seems to work:
private IEnumerator FireContinuously()
{
while (Input.GetButton("Fire1"))
{
[ ... standard shooting code ...]
yield return new WaitForSeconds(shotFiringPeriod);
}
}
Is there a reason why I wouldn’t want to use this self-contained approach instead? Or is it just a matter of Rick looking for a good opportunity to teach “StopCoroutine”?
If it’s the later, I understand. Just want to make sure I’m not missing something.