I am making a bullet hell game, I want to be able to programmatically add and subtract bullet spawners. These bullet spawners listen to the parent object to know when to do their
on_shoot methods. I am coming from Unity so naturally I tried an observer pattern script first, didn't work out. Using signals, I can't figure out how to assign new listeners from the script that emits the signal.
# Declare member variables here.
export var gunCount = 0 #number of weapons
export var health = 1 #health points
export var speed = 150.0 #movement speed
export (PackedScene) var Gun #gun prefab
export var guns =  #list of guns
func addGun(PackedScene, GunCount): #adds guns based on count
for i in range(0,GunCount):
print("%d connected" % i)
for j in range(0,GunCount):
self.connect("shoot", guns[j], "_On_Shoot")
# Called when the node enters the scene tree for the first time.
This is my last attempt at trying to achieve this, but it results in an error that reads
connect: Parameter "p_to_object" is null.