simon.wade Posted May 9, 2024 Posted May 9, 2024 The documentation in SDK 2.18.1 for the World::getNodeByName() function includes a notice indicating that nodes having a possessor are filtered. Is this true? My understanding is that this means you could locate a reference node by name, but any nodes it references would be unlocatable. In practice, it seems that the function does find the contents of reference nodes, so either my understanding or the notice is wrong. Hopefully it's my understanding. :D It's worth noting that the method returning multiple nodes (getNodesByName) does not include the same notice, even though I would've expected the same behaviour. Here's a link to the documentation in question: engine.world Functions - Documentation - Unigine Developer
silent Posted May 12, 2024 Posted May 12, 2024 Hi Simon, Looks like there is currently a bug with getNodeByName() and it's actually returns contents of the reference nodes even if unpack nodereferences is not enabled. We will try to fix this in the upcoming 2.19 release. Thanks! 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
K.Wagrez Posted October 8, 2025 Posted October 8, 2025 Hello, Sorry to refresh such a old question, but since this is actually a follow-up on that (literally), I have a good excuse. We have some behaviors in Unigine Script that used getNodeByName() to retrieve nodes inside node references (since this worked in 2.18.1, and not all of us were aware that it shouldn't have, damn you simon !). The objects that query nodes cannot know the node reference owning the nodes we want. For example we have an object that look for a navigation mesh nested inside a huge station, based on the name. We are migrating to 2.19.1, and our behavior cannot find the nodes (which is exactly what the documentation describe). I know we could use automatic unpacking of node references, however I also know that a lot of our other US script behaviors also deal with node references, and their behavior might be impacted/broken by automatic unpacking. How do we do, if we want specific named nodes, that might be nested (or not, can't know for sure) ? Is automatic unpacking of node references the only way ? Will it break any query or manipulation of node references ? Thanks in advance
alexander Posted October 9, 2025 Posted October 9, 2025 Hi K.Wagrez, You can use this function (it's similar to old getNodeByName(), but slower because it iterates through all the nodes in the world): Node findNodeByName(string name) { Node nodes[0]; engine.world.getNodes(nodes); // get all nodes (include references) for (int i = 0; i < nodes.size(); i++) { if (nodes[i].getName() == name) return nodes[i]; } return NULL; } Best regards, Alexander
K.Wagrez Posted October 9, 2025 Posted October 9, 2025 Unless I'm mistaken, but getNodes seem to have been removed in 2.19.1, from the Unigine script API. engine.world Functions — Documentation — Unigine Developer Or is it not intentional ? 1
silent Posted October 9, 2025 Posted October 9, 2025 Hi Kevin, It seems there is an error in the documentation, since getNodes() is not deleted and works as expected. We’ll need a bit more time to investigate why it disappeared from the 2.19.1 documentation. Thanks for pointing that out. 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Recommended Posts