Godot Version
4.2.1
Question
I have to find all nodes from a specific scene that are light2D?
You can utilize a recursive search through the node tree. For instance:
func get_all_children(in_node, array := []):
array.push_back(in_node)
for child in in_node.get_children():
array = get_all_children(child, array)
return array
Then call this function on the root node and filter out the results:
for element in get_all_children(get_tree().get_root()):
if element is Light2D:
# do something
Thanks