im trying to get myself an altimeter on my game.
`extends Label
var altimeter = self.global_position.y
func _process(delta: float) → void:
text = “Altitude: %s” %altimeter
func _on_launch_pressed() → void:
self.visible = true
`
but it only gives the coordinates on my players scene and not the maps. Is there a way of fixing this?
Making a basic type variable will copy the value, so self.global_position.y is copied once into altimeter, what ever the starting position is will be saved and never updated.
I’d recommend instead getting a variable to a reference of Rocket maybe by get_parent() then use the position of that
extends Label
@onready var rocket: Node2D = get_parent()
func _process(delta: float) -> void:
text = "Altitude: %s" % rocket.global_position.y