Can a node under a instanced scene call get_node() by path?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By genete
:warning: Old Version Published before Godot 3 was released.

The main scene is like this:
enter image description here
So far the ‘Board’ node is instanced (as you can see in the image) and at the same time children of ‘Board’ are instanced by code script.

Can any of the children nodes of ‘Board’ reach the ‘Game’ node using the get_node() by path?

I’ve tried this code:

	var game=get_node("/Game")
	if game:
		print("got game")

but fails.

:bust_in_silhouette: Reply From: Bojidar Marinov

First of all, get_node accepts a filesystem-like path, and scenes, after they are instanced, are just nodes somewhere in the tree.

This means that you can just do get_node("../../") to get the parent of the parent node.

But… there is a slight trick. The root node is /root, and it has the currently-running scene inside it, which means that you can use /root/Game to get to the node you want.

Oh thanks for the quick and detailed reply! I should have know it from a carefully read of documentation am examples.

genete | 2016-04-01 13:14