I am trying to make a health system, starting with 3 hearts.

Hello, i am currently making a small game, it requires hearts/health in it and i cant see any tutorials online. I am kind of new to game development and cant figure out any ways to do it. Please ask for more information if needed.

You can keep track of the health as an integer, and show/hide hearts as that number changes. It’s not too far off of any other health system, you only need to change how the health is displayed.

A for loop can calculate how many full/empty hearts must be shown like so.

for i in max_health:
    if i > current_health:
        # show an empty heart
    else:
        # show a full heart

You can store the heart icons as TextureRects in an HBoxContainer, then you only need to change their .texture property to match the heart state.

thanks, i will try this and hope i can it right :rofl:

i feel like an idiot lol, i have no idea where to go from here.

Your function for updating the health display could loop through the children of hud_health, assuming it only has TextureRect children you can assign matching textures

func update_health_display() -> void:
    for test_health in max_health:
        var texture_rect: TextureRect = hud_health.get_child(i)
        if test_health > current_health:
            texture_rect.texture = load("res://empty_heart.png")
        else:
            texture_rect.texture = load("res://full_heart.png")