How to set a NodePath field to point into a subscene in editor

Godot Version

3.6

Question

How do you guys set a NodePath field in the editor if the target node happens to be in a subscene? A node picker opens for me, but it does not list the nodes from subscenes. It won’t let me type in the path by hand either. There isn’t a logical reason for this not to be possible that I can see. Am I missing something here, or is this just another of those Godot quirks?

Right click on the scene node in the scene tree and enable “Editable Children” from the context menu. That should make scene’s children visible in the assign window.

1 Like

That worked, thanks.
Don’t even need to keep it enabled after.

Like @normalized said. Or, provide variables or functions to get those nodes, by attaching a simple script to the scene’s root node. After that, congratulations! you have just learned encapsulation!

Valid. The subscene is not dynamic in this case, just breaking down a complex scene to ease editing.

If you split the scene off since it’s too big, that probably means you really need decoupling.

Hand written node paths do work, just like ones you did in those onready variables.

However, if accessing a node is the case, you can directly set the variable’s type to a node type, rather than using NodePath.

# 3.x
export(Node2D) var my_node
# 4.x
@export var my_node: Node2D # or Sprite2D, Camera3D, ...

This prevents link breaks when moving nodes around, because Godot will automatically update them.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.