I noticed the stack up of the arrows, while I was completing the continuous fire routine, and before Rick stated his challenge to destroy the arrows with a Shredder (which I went ahead and added anyway) I coded a seperate method, using a Parameter called arrowLife. It detroys the arrow after the duration that arrowLife is set to. I created a range slide for testing purposes and determined that the time it took an arrow to fly from the bottom of the screen is 2.5, so initialized the viable there and everything worked great!
my float paremeter
[Range(.1f, 10)] [SerializeField] float arrowLife = 2.5f;
this is what is called by the CoRoutine:
private IEnumerator FireContinuously()
{
while (true)
{
GameObject arrow = Instantiate(
arrowPrefab,
transform.position,
Quaternion.identity) as GameObject;
arrow.GetComponent().velocity = new Vector2(0, projectileSpeed);
Destroy(arrow, arrowLife);
yield return new WaitForSeconds(projectileFiringPeriod);
}
}
While I am sure they will be useful for other things, this eliminates the need to use a collider, or write a second script.