Can you get a child by name?

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

I’m starting to get my head around the whole tree / nodes thing. I have a main scene and two extra ‘screens’, which are set up as scenes. I have an instance of each scene which I add and remove as children of the main node as required. This all works fine. The buttons to switch between the ‘screens’ are part of the main scene, so easy to use. But I want controls on my ‘screens’ too and the only way that I can see to find them is with something like…


This looks very prone to error and hard to read and looks problematic as I need to add several controls to each screen. Is there a way to get them by name?

:bust_in_silhouette: Reply From: Ch.

get_node(NodePath) or $nodename ?

On Godot 2.x there was get_node(NodePath) and It still exists on Godot 3.0

Please be carefult that If same scene is instanced on the same tree It will be automatically renamed.

Thanks, it was as simple as that :slight_smile:

Farflame | 2018-10-30 15:16