0 votes

I have been trying to code the TextureProgress into a health bar, but it is not working. The value will not decrease when my character comes into contact with the enemy. $HealthBar is the textureprogress. I have coded the decrease in value in the enemy script as:

func _on_Area2D_body_entered(body): #connected signal
    if body.get_name() == "Character":
        body.respawn()
        $HealthBar.value(-15) 

value keeps returning as a null instance

and the health bar code is:

onready var health_bar = $HealthBar

func _on_health_updated(health, amount):
    health_bar.value = health

func _on_max_health_updated(max_health):
    health_bar.max_value = max_health
in Engine by (17 points)

1 Answer

0 votes

in the signal:
$HealthBar.value -= 15

because the value is property not a function so it doesn't use brackets.

by (290 points)

Thank you for your help! I will make changes accordingly.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.