extends Node var bulletsFiredTotal := 0 var bulletsMadeTotal := 0 var bulletArray:Array = [] var bullet = preload("res://scenes/bullet.tscn") func bulletFactory(): var mybullet if bulletArray.size() < 4: mybullet = bullet.instantiate() mybullet.connect("hit", onBulletHit) owner.add_child(mybullet) else: mybullet = bulletArray.pop_back() mybullet.setSpeed(700) bulletArray.push_front(mybullet) bulletsMadeTotal +=1 return mybullet func onBulletHit(bullet, body): #deactivate bullet #put back in queue bullet.setSpeed(1)