Find the node your looking for and print the remote tree!
When you first start out with Godot, you'll quickly learn to add instanced scenes as children nodes within another scene such as a player.
Here is a free GPLv3 gdscript tool node that you can place into any scene and input within the inspector parameters a node you are trying to find in the current scene.
This will either report the node not found, or it will find the node and recursively report to you in the output log the entire remote instanced scene tree. This can be very helpful when writing other code to find and do something in reference to the instanced structure of the remote scene (of if you just need to troubleshoot searching the current tree to find the instanced node). It can be disabled not to flood the logs when you are done using the tool. Don't forget to set your own custom node icon, or just remove that if you don't want a custom icon in the scene tree.

# get_node_tree_instanced.gd
@icon("res://Theme/Icons/tools.png")
extends Node
@export var search_instanced_node_tree: String = ""
@export var disabled: bool = false
var _target_node: Node = null
func _ready() -> void:
call_deferred("_locate_target")
func _locate_target() -> void:
if disabled:
return
_target_node = _find_ancestor_by_name(search_instanced_node_tree)
if _target_node:
_print_node_and_children()
return
_target_node = _recursive_find_by_name(get_tree().get_root(), search_instanced_node_tree)
if _target_node:
_print_node_and_children()
return
print("Instanced Node Not Found: \"" + str(search_instanced_node_tree) + "\"")
func _print_node_and_children() -> void:
if _target_node == null:
print("No node to print")
return
print("Found node:", _target_node, " name:", _target_node.name)
_print_children_recursive(_target_node, 1)
func _print_children_recursive(node: Node, depth: int) -> void:
var children: Array = node.get_children()
if children.size() == 0:
if depth == 1:
print(node.name, "has no children")
return
for child in children:
var indent: String = " ".repeat(depth)
print(indent + "- " + str(child.name) + " : " + str(child.get_class()))
_print_children_recursive(child, depth + 1)
func _recursive_find_by_name(root, target):
if root == null:
return null
if str(root.name).to_lower() == str(target).to_lower():
return root
for child in root.get_children():
var found = _recursive_find_by_name(child, target)
if found:
return found
return null
func _find_ancestor_by_name(target):
var cur = self
while cur != null:
if str(cur.name).to_lower() == str(target).to_lower():
return cur
cur = cur.get_parent()
return null
We have some other more complex Godot tools, scripts plugins and addons on our Itch.io page.
