Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | LimeLite |
Hello,
I’ve been developing this rhythm game, (I know it’s quite ambitious for my second game on this engine) and I’ve come across a recurring problem: I can never seem to effectively call variables from other objects.
I’ve had this problem before with a group of position2d nodes trying to communicate with each other, but those were all children of a single node so I just used:
var pos = get_parent().get_node("Position2D")
However now, I am trying to call variables from a node in a different scene, and I keep getting an Invalid index: null instance error. Any advice would be appreciated, as i am very new to this engine.
code for the variable in question:
`func _on_Area2D_body_entered(body):
var piss = get_parent().get_node(“Player”)
if "Player" in body.name && piss.ATK == false:
piss.HP -= 1
print_debug (piss.HP)
queue_free()`