Skip to reading
GDScript Programming & Godot

43. Reach an existing model without guessing a node path

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView illustrations
Code example
func run() -> bool:
    var nodes: Dictionary = Runtime.get("entity_nodes")
    var object_node: Node3D = nodes.get("archive_door") as Node3D
    if object_node == null or not is_instance_valid(object_node):
        return false
    Log("Rendered node class: " + object_node.get_class())
    return true

This is an intentional lower-level bridge. The entity_nodes table is runtime implementation data in this build, not a general stable registry API. Guard it and retest extensions when updating PCA. A character can be replaced/rebuilt, so a cached Node reference can become invalid.

The returned node may be a wrapper with an imported model below it. Use known child names from your own scene, or a constrained find_child/find_children search. Do not assume that every asset has the same hierarchy.

For ordinary visibility, animation, position and inventory changes, use the PCA action/proxy. Native node manipulation is for work outside that higher-level surface, with ownership and restoration handled deliberately.

Figure 14. The running preview confirms that the rendered archive_door node is a Node3D; its model is below that wrapper.

Page 52 of 378Permalink
Go to page