Find a node?

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

How do I get a node by searching it.

onready var objectA = get_node("blocksA")

I need to find it because the position and child could be different every time.
Thanks for help.

var currentObj = get_tree().get_nodes_in_group ("group")[0]

usurun | 2019-06-15 00:17

:bust_in_silhouette: Reply From: Thomas Karcher

get_node returns exactly one node specified by the path parameter, not all nodes matching this name. To find all nodes matching a certain criteria, you could assign them to a group (e.g. “group_blocksA”) and access them with

onready var objects_A = get_nodes_in_group ("group_blocksA")

(see SceneTree — Godot Engine (3.1) documentation in English )