Dear community,
I try to implement save/load functionality, and come to two errors:
- Fired bullets appear lose userObject in collisionlistener
- CameraNode stops working.
1.First error: I have this code triggered from ActionListener:
public void load() { String homeDirectory = System.getProperty("user.home"); String fileName = "\\Saves\\" + "QSave.j3o"; assetManager.registerLocator(homeDirectory, FileLocator.class); Node loadedNode = (Node) assetManager.loadModel(fileName); physicsSpace.removeAll(rootNode); rootNode.detachAllChildren(); List<Spatial> RootChildren = loadedNode.getChildren(); for (Spatial child : RootChildren) { rootNode.attachChild(child); physicsSpace.addAll(child); } }
If I save the game at the moment when character have fired some bullets and reload scene (without exiting game) , then once bullet touches the destroyable object, no collision is registered.
The CollisionListener class in the event “collision” has event.getNodeA() and event.getNodeB() as null.
I see the attribute “nodeA” exists (event.nodeA is not null, but the method getNodeA/B is using internally “getUserObject” and userObject is empty.
Am I doing physics update in incorrect moment?
Which method should be used for that?
I use sequential threading for physics, just in case it can matter
2.Camera - here I do not get the reason at all.
In the AnalogListener I see cameraNode is extracted, new position/rotation is applied, but somehow on the screen camera is not changed.
Please help if you know something, I spent this whole day debugging on it