Hey folks,
i started using jme for an student projekt a few weeks ago, so don't be too hard :).
I've the following problem:
If have a game where some objects ( Worms ) should shoot straight into the camera ( the player), the shoot works, i mean i use jme physics and i create a dynamicPhysicNode with a sphere in it and set a force, so that the sphere fly through the scene.
No the Problem, i want to get the position of an object so that i can shoot from that position and i want to shoot at the camara, so i need the camera position. i think the folowing code should do that but it doesn't work.
// get local translation of the node with the object ( the worm) in it
posShoot=dynPhyNode.getLocalTranslation();
// create an physics node with an sphere in it
DynamicPhysicsNode node = scenes.tools.ObjectFactory.get().createObject();
node.setLocalScale(5);
node.setName("physics node");
node.getLocalTranslation().set(posShoot.x,posShoot.y+30,posShoot.z);
direct.set(posShoot);
direct.add(gameModel.rootNode.getLocalTranslation());
direct = direct.subtract(gameModel.cam.getDirection());
node.addForce(f.mult(direct));
gameModel.rootNode.attachChild(node);
gameModel.rootNode.updateRenderState();
gameModel.rootNode.updateGeometricState(0, false);
So maybe someone can tell me what i do wrong?
Sometimes this code let my app crash and eclipse say it's and java runtime error or something like that, but don't tell me any usefull information.
Hope somebody can help!
Thanks and greetings
Tobias