Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created March 1, 2025 14:29
Show Gist options
  • Save lamarmarshall/ceae22170ae140f28c7b79bf6662dd3b to your computer and use it in GitHub Desktop.
Save lamarmarshall/ceae22170ae140f28c7b79bf6662dd3b to your computer and use it in GitHub Desktop.
godot, gdscript, getter, setter
var current_health: int:
set(health_in):
current_health = health_in
print("health was changed")
label_3d.text = str(current_health) + "/" + str(max_health)
var red: Color = Color.RED
var white: Color = Color.WHITE
var blended_color = red.lerp(white, float(current_health) / float(max_health))
label_3d.modulate = blended_color
if current_health < 1:
get_tree().reload_current_scene()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment