![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Yamz |
![]() |
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")