Im Struggling To Understand how to get this to work so any help would be appreciated.
Im trying to update the label With The current score.
The Label is in the main scene, Its a child of a canvas layout while the collectable is its own scene that isn't called in the scene, its called by a script after a timer.
Here is my current on-hit update score script.
func _on_Collectable_body_entered(body):
if body is KinematicBody:
if (body.get_name() == "Player"):
global.score += 1
print(global.score)
queue_free()
else:
print("gone")
queue_free()
This works perfectly! it updates the global.score.
But how can I get it to update the label with the global.score variable after the collectable is removed?
I've tried the "$" way as suggested in the "build your first game" docs. This doesn't work.
get_node doesn't find anything at all.
I've tried preload. Ive added a function in the label script and it doesn't find it or crashes.
All i want is for the score to be updated. I've been trying to work out how to update it via emit_signal But this still isn't working. I'm really struggling with this issue. Can anyone help me with this problem?
I think I've explained it correctly.
Just in case:
When the player hits the collectable, The collectable being in its own scene, it then updates the label with the current score and constantly updates.
Thank you =)