+1 vote

Currently on my player script there's this code that emits its current health when the game starts:

signal update_health(h)

func _ready():

I've been trying to connect it to the top node on my tree so it can update the GUI by using this code (player node is currently on a group called 'Players'):

onready var in_game_HUD = $CanvasLayer/InGameHUD
onready var player = get_tree().get_nodes_in_group("Player")[0]

func _ready():


func update_health_UI(h):

While the "isconnected()" returns true, it doesn't seem to run the "updatehealth_UI" and I dont seem to understand why, since connecting this signal with Godot's GUI works, but sadly I cannot use this method for my project.

Godot version Godot 3.3.2.stable.official
in Engine by (27 points)

2 Answers

0 votes

maybe you are emitting the signal before it is connected? since both are on the ready func if your player script is running before the other script the signal doesn't emitted at the right time.

by (452 points)
edited by
+1 vote

Not sure why you get positives however this line


It's supposed to read as

player.connect("update_health",self, "update_health_UI")
by (6,264 points)
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 Frequently asked questions and 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 [email protected] with your username.