I have a situation where when an opponent dies I get points for it. I would like to do this with a signal, but I don't know how to do it. I have a Main Stage and it has a script that adds a player to the map and every one second another opponent.
I have a problem with signals
Signals can use arguments as well as functions, and emit_signal
function take those as parameters. For example:
# Opponent script
signal died(position)
...
func die():
...
emit_signal("died", position)
Then, when you create opponent in Main Stage
script, you should connect opponent's signal to method in Main Stage
script:
# Main Stage script
func create_opponent(...):
...
opponent.connect("died", self, "on_opponent_died")
# Connected function must take the same amount of arguments as in opponent's signal
func on_opponent_died(position):
...
You should read this for a better understending.
a year later
Megalomaniak added the Godot Help tag .