Topic was automatically imported from the old Question2Answer platform.
Asked By
wolvertox
I have a boundary that when passed emits a signal to stop an enemy from shooting, but when I add two enemies to a scene, if just one of them passes the boundary they all stop firing.
Or, as an alternative to @exuln’s (perfectly valid) answer, you could continue to use the generic signal but pass the specific area along with it. Then, each receiver can check the included area argument and only act on the signal if they are the specifically intended receiver.
So, (based on your above code) emit something like this:
emit_signal("halt", area) # pass the specific area along in the signal
And, in the enemy signal handler, something like:
func _on_halt(area):
if area == self:
# signal was intended for THIS INSTANCE - process it.
So, essentially, while every enemy will receive the signal, only the intended enemy will react to it.