How to go up and down a scene tree

Godot Version

4.5

Question

I know that you can go down a scene tree I would use $node but I don’t know how to go up a scene tree. Furthermore I would like to know if I can pass up values from one node to another. This is because I’m making a strategy game and I’m currently trying to figure out how to get the Swordsman health to be displayed on the HUD.

Scene tree:

That said, you shouldn’t really be changing any properties in the nodes “above”. A need to do this is often a sign of bad architecture. Ideally, parents should control stuff underneath themselves, and upward communication should happen via signals. Let your hierarchy of responsibilities respect the scene tree hierarchy.

So ideally the HUD should be storing the health of the swordsman?

No, the swordsman should store its health but the hud should read it from the swordsman instead swordsman itself setting stuff in the hud.

1 Like

Ah, okay thanks. But I do have more questions, how do you navigate the documentation so easily?

Search. And knowing what to look for to a degree.

1 Like