[Solved]Getting nodes from .j3o made in SceneComposer

Hi!



I have a map made in SceneComposer and I wanted to visually set the spawning point by creating a node and moving it around (I know I could do it with code, but I’d like it to be this way if possible).

Is there any way for me to retrieve this Node in my code by searching for name somehow, like .getNode(“SpawnPoint”)?



Thanks in advance!

yep: node.getChild(“SpawnPoint”)

will search down the tree of nodes and find that point.



I, personally, prefer using user data. I set a boolean with it’s key being “spawn point”= true. Then I manually climb the node tree. But I have several values on my node.

This code here is from Node.java:

[java]

public Spatial getChild(String name) {

if (name == null)

return null;



for (Spatial child : children.getArray()) {

if (name.equals(child.getName())) {

return child;

} else if(child instanceof Node) {

Spatial out = ((Node)child).getChild(name);

if(out != null) {

return out;

}

}

}

return null;

}[/java]

So you can do something similar, and check the userData. Or just use the node name which is quite easy.

1 Like

Thanks, I didn’t think about that you could convert a Node out of the map Spatial!

Works now :slight_smile: