how to get the son of a node if i am in another node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Yamz
:bust_in_silhouette: Reply From: kidscancode

You can get any node in the tree by providing the correct path. Node paths work just like folders on your operating system. get_node("..") gets the node one level up and is equivalent to get_parent()

Let’s say you have the following setup:

-NodeA
+-- ParentA
|    +-- ChildA
+-- ParentB
     +-- ChildB

Your script on “ParentB” wants to get “ChildA”. The path is .. (goes up one level to “NodeA”) followed by “ParentA/ChildA” You could write this in two ways:

var node = get_node("../ParentA/ChildA")
# or
var node = get_parent().get_node("ParentA/ChildA")