Hello i have a question?

Godot Version

4.4

Question

how do i make the progress texture update when i am dealt damage

Do you wanna change the texture?
Can you say more specifically :slight_smile:

Hey, you can update the TextureProgress bar by changing its value whenever damage is taken, like this: $HealthBar.value, damage amount. Just make sure the min_value and max_value are set correctly. That should make the texture update to reflect the current health.

1 Like

yeah, i have a texture progress bar but i dont know how to make it work with the player life


Ohh that’s very easy you can use this code

#Player script

func _process(delta):
    $path_of_your_texture.value = health #your players health
#you can drag your progress texture node into the script

so i just put this on the player code and then i get tree of the ui code?

Yes your tree should look like

Player
-----Hp
----------margincontainer
------------------------textureprogressbar

its giving me a problem

Share it.also here’s the method


yeah i did this, but my game is 3d so maybe that is the problem? or maybe is the way i calculate hp?

Can you share a screenshot of your code?


Ohh there’s the problem it should be @export not @onready
Like this

@export var health:int = max_health
1 Like

it tells me this but i dont understand why since i gave it the ui on the player tree


1 Like

It says node not found it should be

$Hp/MarginContainer/TextureProgressBar

Just copy it and paste it :slight_smile:

3 Likes


thank you very much its working

1 Like

You’re welcome:D
That looks sick btw !

1 Like