Hi all, I want a little debug window that will show stats like HP, velocities and other variables during playtesting. This is to avoid having to add print statements strewn throughout the code. I managed to get this working with the global variables found in the games' main script, but I can't figure out how to display localised stats. I have also tried to @export these variables on the character, to no avail.

Working example for the character's HP (global variable in the Game.gd script):

extends Label
func _process(_delta):
	text = "HP: " + str(Game.characterHP)

Non functioning example for the character's X velocity:

extends Label
func _process(_delta):
	text = "Vel X: " + str(get_node("../../Character/new_character").velocity.x)

The error I receive is....

Invalid get index 'velocity' (on base: 'null instance')

Any help as always, appreciated!

This error means that the node "../../Character/new_character" does not exist. You probably have the wrong node path.

    Zini Yeah, that is what I'm struggling with lol.

    I managed to find a solution for this, but I think it's uber overkill.

    In this main Game.gd script with all the global variables that do work, I added a reference to the character like this.

    var character : character

    And then in the label, I merely added

    text = "Vel Y: " + str(Game.character.velocity.y)

    This works! However, I'm, sure there's a simpler way (like if I can only get the correct 'path' in the get_node() parameter, not sure why this is so difficult.

    What may also be happening is you may be referencing something that is not available as a resource yet. ‘_process(delta)’ starts whenever a node in ready but that doesn’t mean all processes start simultaneously.

    However you solved it. By referencing the object you’re looking for at the start/declarations, you avoid that problem. You could alternatively assign that abstraction at ready.

    Cool cheers for the helpful replies!