Hello Guys,
i´m pretty new to Godot and trying to send my Playerdmg to an enemy via an autoload script, but for some reason i´m not able to make it work. Guess if i´m able to get kind of understanding of signaling, i will help me in future on things like signaling exp on enemy kills and so on.
I´m really helpful for any advise, here are the parts of the different scripts:
Playerscript:
var playerdamage:int:
set(value):
playerdamage = value
Messenger.PLAYER_DAMAGE_CHANGED.emit(playerdamage)
print(player)
Try connecting the signal like this: Messenger.PLAYER_DAMAGE_CHANGED.connect(on_player_playerdamage_changed)
Your way of connecting should work too, but it doesn’t always for some reason…
edit: oh you also typed it wrong, “Player_DAMAGE_CHANGED” should be all capital
Thank you for the replay, i changed the letters to be all Capital in my script. Still not be able to add the damage in my enemy script. Am i supossed to connect the signal the way you suggested in my playerscript?
build in some print functions:
Playerscript:
var playerdamage:int:
set(value):
playerdamage = value
Messenger.PLAYER_DAMAGE_CHANGED.emit(playerdamage)
print(playerdamage , “transmitted”) ## Works with the correct value
Enemy:
func _ready():
Messenger.connect(“PLAYER_DAMAGE_CHANGED”, on_player_playerdamage_changed)
print (“connected to Messenger”) ## Prints