Sorry dumb question but how do I move a var from my player to my enemy script?

  • alfredbaudisch replied to this.
  • 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

    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

    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.