• 2D
  • Transferring a value of a variable form one node script to another node script.

As the problem says. I am trying to move a fuel variable form my player to my hud node so that i can display how much the player has left. The player node is it's own instance but both the instanced player and the control node i am trying to send the data to are children of the same world node. What is the best way to get that value from the player to the control node?

I have thought of using signals but i am not sure that is a good way and am wondering if there is a more standard way?

Signals would be my first go-to. I'd say give it a try and only start thinking of alternatives if it really can't work for you.

So I guess my question is how would i add the variable to the signal and how would i retrieve it on the other end?

If you're new to Godot I'd prioritize figuring out how to setup a "singleton" or a class with global scope which everything can access first. With one of those you could either have references to the instances you're keeping track of or just store data like fuel there.

That being said, signals are a big part of godot and you'll have to figure them out anyway. They are built in to most if not all of the game classes allowing intercommunication between nodes. IMO a bunch of custom ones will lead to a mess of spaghetti inter-communication so I usually only setup custom ones when I'm pretty sure the communicating nodes won't need to be sharing their "conversations" with others.