Automatically spawn and place objects by supervisor? #4487
Replies: 2 comments 1 reply
-
You should use wb_supervisor_field_get_mf_node to retrieve a reference to the node you just inserted. If it was inserted last, then you should set the index value to -1. |
Beta Was this translation helpful? Give feedback.
-
Well, in practice importing from WBO is not that common to begin with. Most people create the object as a PROTO file (as it also has the extra benefit of exposing parameters that allow you to alter the end-result, for instance in case of a box you can expose parameters for its size, appearance, or others in order to generate multiple different object from the same entity). Once the object is defined as a PROTO file, it can be spawned from string instead, and then you can attribute whatever DEF you wish to every instance, along with configure each of them by providing different parameters: |
Beta Was this translation helpful? Give feedback.
-
This might be a beginner question, but I can't find any information regarding this in the documentation.
Say I have a supervisor and want it to automatically place objects (e.g. boxes) in the world. I have created an object and exported it as .wbo file. I now load that file in my supervisor controller using
importMFNode
. How do I now identify the node that I just inserted? I can usegetFromDef
to modify this node, but if I import another instance of the node, there will now be multiple defs andgetFromDef
seems to not work anymore (i.e. modifying the position has no effect). It also seems like modifying the def is not possible through the supervisor.How is this problem usually solved? Is it possible to get a reference to e.g. the last node in the scene tree after running
importMFNode(-1, "filename")
?Thanks for clarifying!
Beta Was this translation helpful? Give feedback.
All reactions