What does get_node("../../../") do?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By godotnoobperson

I’m studying this asset:
https://godotengine.org/asset-library/asset/693

In res://Inventory/UI/ItemSlot.tscn, it has this line at the top:
onready var inv_comp = get_node(“…/…/…/”).inv_comp

What does that do?

I understand get_node is supposed to get the node using the node name and its parents. But from what I know “…/” is supposed to address its parent. So in this case, it’s 3 parents above. The script was added to the highest parent, so I don’t know anymore.

Also what does “.inv_comp” do? I see that it’s a variable?

:bust_in_silhouette: Reply From: GameSpy

How do you know it is the highest parent? This scene could be instanced inside another scene during runtime. get_node(“…/…/…/”) returns null when attached to highest parent.

Thanks. I understand it now. It’s calling a variable in a node 3 parents higher in the scene it is instanced in. This particular node is being added during runtime so it confused me.

godotnoobperson | 2020-08-12 05:15

You gotta press the tick icon in my answer so that the question doesn’t appear as unanswered.

GameSpy | 2020-08-12 13:35