Sorry dumb question but how do I move a var from my player to my enemy script?
How do I move a variable from node to node
- Best Answerset by The_Grass_man
You don't "move" variables. Variables are local to a script. You can either define a new variable in the other script. You you can access a variable from any other script. For example.
var player = get_parent().get_node("Player")
var player_health = player.health
The_Grass_man You can also right-click a Node, check Access Unique Name
And then in the code: %Player.health
Oh yeah, I forgot that was added.
cybereality Same, I still haven't used it. Now that I posted it here I'll refactor some things to take advantage of this.
I always cache my nodes, so it's not a huge deal. However, for UI and deeply nested stuff, this will be great.