|Topic was automatically imported from the old Question2Answer platform.
Hello, I am new to godot and find it intriguing due to its great flexibility.
As I have a VRML background, I am trying to figure out what the closest equivalent of the VRML DEF-USE mechanism is. VRML has a scene graph which allows for multiple parents for the same node. Here is Panda3D explanation of this concept:
A VRML node can be inserted a second time somewhere else in the scene graph by just referencing (“USEing”) its “DEF” name. The second use is not a copy and strictly speaking is not even a pointer to the first use of the node but is materially the same node. The same node then just has two parents and exists in multiple places.
One way to do something like this in Godot seems to be instancing of a scene (which may have only one node). However, after reading the documentation a few times and through answers here at the forum, I am still not quite sure what instancing exactly does. The method documentation to .instance()
just repeats ‘instancing’ without explanation. The doc Introduction
does not use the word ‘copy’ but also not the word ‘reference’ or ‘pointer’.
Digging further, a PackedScene is a Resource which is a reference counted object, so presumably .instance() creates a new, light-weight object which only maintains a pointer back to the scene root node. Is that more or less correct ?
The other option to achieve multiparenting(-like) behavior seems to be reuse of Resources. In fact that seems to be a closer fit since Resources are not loaded more often than once. However, a Resource itself cannot be a Node in the scene graph. For that a .new() call for constructing a new object seems necessary, for each placement in the scene graph. Is that about correct ?
Another way to ask the question is to go back to the Panda3D way of instancing. What would be the closest equivalent in Godot ?
is the method which is used by scene.instance().
From what I can tell it goes through the nodes of the scene and will construct a new node if it had not already been constructed for another instance, or otherwise reference this already constructed node.
Andreas Plesch | 2020-02-11 15:55