Create selectable node3D without children in editor on @tool script

4.2.1 stable


I’m building an @tool script to generate a bunch of node3Ds (probes) in my scene. I am visualising those by generating a simple sphere mesh, and I would like those probes to be selectable in the 3D viewport. The only way I can seem to make those nodes selectable is by setting the owner of the sphere mesh instance that I generate to get_tree().get_edited_scene_root(), and since this concerns hundreds to thousands of nodes, this severely clutters up my scene tree: it shows a child node in the tree for each of my hundreds of probes.

I’m wondering if there is a way to create a script that extends Node3D, allowing me to visualise and select that node3D in the 3D editor, without adding children to that node in the scene tree. Even better would be if I could make it so the probes themselves don’t show up in the scene tree, but are still selectable in the 3D viewport. Another possible (though not preferred) solution would be making the probes be collapsed by default in the scene tree view when they are spawned.

Additionally and related to this: when I add a mesh instance with the scene tree set as the owner, when I select my sphere it will select that mesh instance node, while I’d like for it to select the parent node (probe) instead.

Essentially I’m just trying to achieve a similar result as if you’re placing a node with an icon, such as an audiostreamplayer, that you can select in the 3D viewport, but with a custom class instead. I’ve unfortunately had no luck searching for this online.

Any ideas on how (or if) I could achieve a solution for these issues without engine modifications?

Result I’d like, clicking a node in the viewport (or even without the nodes showing in the scene tree):

Behavior I currently have:


I have never used it, but maybe it would help to mark the nodes as internal while adding them: Node — Godot Engine (latest) documentation in English

That works exactly as I hoped it would, thanks!

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