Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Spaliasum |
I want to check what is the value of the variable var from another scene.
For example, I have a scene level1 and I want to make a check in it.
There is a variable var in another scene (is_dead = false)
When a character dies, the value of the variable changes on true.
How can I check this through the operator if?
I not cool in code. but there is mine
extends Node2D
onready var Gameoverstats_player = get_node(“/root/Player”)
func _process(_delta):
$Stats/CanvasLayer/Label.text = str($Player.coins)
#if $“/root/Player”.is_dead = true (the is the problem)
$Gameoverstats/CanvasLayer/Label.show()
Spaliasum | 2020-08-09 14:35
Don’t understand why you got $"/root/Player"
and $Player
but this should be enough:
if $"/root/Player".is_dead:
$Gameoverstats/CanvasLayer/Label.show()
without = true
, actually it should be == true
with double =
but since it’s a boolean you can omit it.
Dlean Jeans | 2020-08-09 16:24