Use player variable in another node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nowaymad123

I have a player node and an area 2d node, I want the area node to only work if the player is not “dead” as i call it.

func _on_FallThroughFloor_body_entered(body):
if body.name == “Player” and !hasBeenUsed:
yield(get_tree().create_timer(3), “timeout”)
$TileMap2.queue_free()
$SCRIPTSTUFF/PLAYERSTUFF/Player/die.play()
hasBeenUsed = true
print(“should fall”)

anyways, i want the variable which i use in the player node called
var dead = false to be used here like this:
if body.name == “Player” and !hasBeenUsed and !dead:

how can I do this? I know about a singletons but I don’t wanna do it that way, I wanna do it just through normal code can I do that?

Also I connected the area 2d to the main node of the scene!

nowaymad123 | 2023-06-25 17:46

As the if statement here confirms that body is the player, body.dead should suffice.

spaceyjase | 2023-06-25 21:39

:bust_in_silhouette: Reply From: Meepophobia
if body.name == "Player" and !hasBeenUsed and !body.dead:

If I’m not mistaken the body variable is the reference to the player which you can access its properties.