Godot Version
Most Recent
I don’t understand why I can’t reference it. I referenced it the same way in another part of the code.
I know you said you did the same thing elsewhere in your code, but my initial guess is that the definition of deaths_label on line 6 isn’t doing what you’re wanting it to. It’s not an answer per se, but if I were you, I would try using get_child on DeathsLabel and see if that works. Or, you could try going about this using signals and on emit, pass the text that you want to change the label to ![]()
Could you show the function Deathcount.add_death()?
Its in a global script so that - as the game resets on death.
This is it:
extends Node
var deaths = 0
func add_death():
Deathcount.deaths += 1
I wanted to update the label here but it seemed to be even harder as the label isn’t ever loaded in when the game resets.
You probably could put the label inside a Scene + death counter script. Autoload can take a script or a whole scene.
Do you have any other kill zones that are missing a label child? Maybe try adding to your ready test:
func _ready() -> void:
if deaths_label != null:
# etc, your print
else:
push_warning("I, %s am missing a death label!" % get_path())
make sure to paste scripts between three ticks for formatting like so
```
type or paste code here
```
Okay, so that kinda solved it… except now all my enemies have a label with them as they move. I tried using label.queue_free() but it does not work as intended.
Another issue I have my deaths_label is placed in the level relative to where the killzones are.
I went back to checking for null. This does the job for now. I don’t understand why it checking it for the slimes when it is put right into the game. Its not in the killzone scene at all.
At this point I recommend moving your death label into the same scene as your “Deathcount” autoload. So many enemies doing the same thing will be a mess to organize and keep up.