- Edited
I put arguments into a signal like this:
my_signal(arg1,arg2)
But not telling the signal there will be arguments beforehand works just fine too?
signal my_signal
func _ready():
my_signal.connect(_my_function)
my_signal.emit(1,2)
func _my_function(arg1,arg2):
print(arg1,arg2)
And if i try to do it the way the docs say, i get an error message. "Method expected 0 argument, but called with 2." But there are 2 arguments, old_value and new_value. So why the error?
var health = 10
signal health_changed(old_val, new_val)
func _ready():
health_changed.connect(print_health)
take_damage(1)
func take_damage(amount):
var old_health = health
health -= amount
health_changed.emit(old_health, health)
func print_health():
print(health)