#Problem with singals
1 messages · Page 1 of 1 (latest)
what's a @tool script?
If you are adding this node with add_child(). That means you are doing it while the game runs.
At that point you cannot connect the node from the editor.
Because it does not exist in the editor.
I am not sure what you're trying rn.
But code only runs while the game is running. And changes that happen in the game do not affect your project. They stay in RAM
So, i have the Player and the Glove. Glove will become Player's "subnode" when the game starts, and it has a state. I want send the Glove's state to the Player node, emitting it with this Signal
that must not be the best way to do that tbh
You would have to connect them in code.
Like, if the script is in the glove:
func _ready():
var player: Node = get_parent()
glove_signal.connect( player.on_glove_does_the_thing )
Now my code is like this
Glove Script
state = "idle"
var player: Node = get_parent()
glove_signal_state.connect(player.get_glove_signal)
func _process():
[...]
emit_signal("glove_signal_state",state)```
Player Script
$StateLabel.text = state```
i'm getting Invalid access to property or key 'get_glove_signal' on a base object of type 'Window'. error
so i assume it wasn't possible to connect the signal
I think there are many issues here.
First this seems to be an autoload, so it is a child of the game window and not of the player. (well, it could be child of both)
Then the naming convention for the player signal leads me to believe that this function is not for what you want it to do
wait what, child of the game window?
the error says the parent is of type Window.
The game window is also a node, the top one of the entire tree (not visible from the editor)
oh ok
The only way to have a node that high up in the tree is to parent it to the root or to make it an autoload, so those are my suspects rn
So, when i did
add_child(glove)```
I turned this a node from the window?
i think you have it as an autoload too. So you have 2 in total
Ok, now i need to find out whats autoload just a second
prob an option
from the editor
it would be in Project>Settings>Globals
nono there are no autoloads
so theres prob a mistake here
the Debugger tab, specially the Stack Trace window, has more information during the crash. Try triggering it again and checking that