Sending a signal to a scene that isn't YET in the same scene as the one sending it

Godot Version

v4.2.1 stable

Question

hello, i’ve been working on my first project in godot without beeing guided through a tutorial, rn i’m stuck at a point because i’m trying to make a system so the player can get his wand out and in by pressing one key.
i managed to make the wand go out but i can’t figure out how to put it back in.
what i wanted to do is send a signal to the wand scene that only gets emited if the key is pressed and my var “wand_out” is true, the issue is that my wand scene isn’t in the main scene (level).
should i just instantiate the wand scene as a child of player in the level scene or can i do what i want through some other ways ?
a little pic


i can’t put the wand code but there isn’t much in there yet except a function that SHOULD run queue free when the signal is received

You are using signals wrong, what you need to do is connect the signal to a function on the wand:

well except if that’s not what you meant i did in fact connect the signal to a function or atleast i think i did.
image
in that specific part of the code (i removed everything i put to test if something would change), the code sends a signal called get_wand_in that is connected to the function _on_get_wand_in in the wand scene that should execute when the conditions are met, maybe i don’t get it but i think that’s what you meant

Can you show the error on the console?

well there’s no error it’s just that the wand doesn’t disappear when i press the assigned key, i’ve tried to put something to print to see if the signal is received but it isn’t…
i think it’s because i didn’t use the UI godot gives you when connecting the signal but that’s because godot doesn’t let you connect stuff that isn’t on the same scene
i guess i could just put the wand as a child of the player scene but my main fear are optimization issues…
speaking of optimization, having the wand as a child of the player would mean it’s displayed by default and if i hid it i suppose it’ll still take some place in memory so i’d have to queue.free it until i need it
if this sort of stuff doesn’t impact game performance i guess i could just put it and that’ll simplify everything, also my game is a roguelike where you go room to room so i don’t even know if i should be worried about this kind of stuff but please do tell me

Please read the “connect” section of the link above. If you didn’t use the manual way of connecting a signal, then you should do it via code.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.