Using the tutorial I found, I still don’t get how to connect a signal after its been emitted. Currently what I’m trying to do is have a button connect to the swordsman script which then emits a signal that passes on a health value, which should be connected in the EnemyStorage script which should then print the health value passed on by the Swordsman. However, I’m struggling with connecting the swordsman to the EnemyStorage.
it is not that complicated, make use of a singleton.
Create a new script that extends the node class, and define one or more signals on it.
(just put in : “signal SwordsmanInteraction”), save it as SignalManager.gd
In the Project Settings, navigate to the Autoloads tab and register your new script as an auto-loaded node.
Connect another node to the Events singleton via code like you would with any other: SignalManager.connect(“SwordsmanInteraction”, self, “_on_Events_SwordsmanInteraction”).
(this will be on the enemy storage script)
create the function, func _on_Events_SwordsmanInteraction(health): your code
from any script in your project, you can then write SignalManager.SwordsmanInteraction.emit(health) to emit the corresponding signal.
(this will be on the swordsman script)
The singleton will act as a relay, whoever is connected to the signal will receive the emit.
The emiting script doesnt need to care who is connected to the signal.
after taking a break, I took a shot at it again, using the event singleton made my life a lot easier and I wasn’t able to connect the signals between nodes because I was using the godot-3 method while I was using godot-4. Thank you everyone for your help