How can attach/detach node thread safely?

Hi all! I have some problem with JME3.



I cant understand how can attach/detach node from non-render thread safely. I read about GameTaskQueueManager class in JME2, but I cant find it in JME3. What should I do for changing scene(attach new nodes, change positions) thread safely?



Thanks.

1 Like

You should only modify nodes that are attached to the rootNode inside simpleUpdate(). i.e.

[java] @Override

public void simpleUpdate(float tpf) {

rootNode.attachChild(myNode);

myOtherNode.removeFromParent();

//etc

}[/java]

You have to do everything thread-safe when a Spatial is part of the scenegraph, not just attaching and detaching, also moving etc.:

[snippet id=“10”]