![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | andrebariani |
Based on the Design the GUI tutorial and the Control the game’s UI with code Tutorial, I tried to implement those tutorials in my project. In the GUI script, when I tried to assign int MAXHP
to a TextureProgress node (which on the code is the variable bar
called as onready var bar = $HBoxContainer/Bars/Bar/Gauge
) in the following code:
func _on_HUD_start_instanced(MAXHP):
bar.max_value = MAXHP
bar.value = bar.max_value
It returned the error Invalid set index ‘max_value’ (on base: Nil) with value of type ‘int’.
Why is it returning Nil, even if the Gauge node is a child of GUI?
what event did you connect to _on_HUD_start_instanced
?
volzhs | 2018-06-08 03:51
I’ve connected with an emit_signal("start_instanced", MAXHP)
in the HUD script. The HUD is a CanvasLayer and the parent of Interface (Control node). The Interface is the parent of an instanced GUI scene, so the problem should be on the GUI scene. I’ve called print(MAXHP)
in the first line of _on_HUD_start_instanced
and it is the correct int value (which is 6).
andrebariani | 2018-06-08 13:07