So the problem is, I had nodes like characters, so the player and enemys are nodes. But when I try to get the position in the simpleUpdate() It returns the same initial position always.
So I search to resolve this, and I find this: upadateWorldVectors() that looks like it’s all I need to resolve my problem, but when I try it in jme like Node.updateWolrdVectors() jme give mark it with red line like it doesn’t exist
So the thing is why It does not work?
Here’s my code If there’s anything else you need to know
[java]
CapsuleCollisionShape pcs = new CapsuleCollisionShape(2f, 4f, 1);
theplayer = new CharacterControl(pcs, 0.01f);
theplayer.setJumpSpeed(20);
theplayer.setFallSpeed(30);
theplayer.setGravity(30);
player = (Node) assetManager.loadModel("Models/garret/Cube.mesh.j3o");
player.scale(0.5f);
player.addControl(theplayer);
rootNode.attachChild(player);
Well I take look to the com.jme.scene.Node class and I found there is no updateWorldVectors() method I don’t know if this is the way it is or my Node class is incomplete or something
updateWorldVectors never existed…i don’t know where you found this information.
you don’t need to update anything the engine takes care of it for you.
There must be something else going on.
Posting the full code would help, but at first glance I’d say you never attach the bulletappState to the stateManager.
I checked up the javadoc of jme.scene.Node and found the updateWorldVectors(); but then I re-install the jme and it does not appear in the javadoc, so I think It was a installation problem.
But, well now… my problem is to set the enemy Node to look at the player node, soIf you can help me it would be really greate.
I tried out the:
[java]
lookAt(player.getLocalTranslation(), enemy.getLocalTranslation());
[/java]
It really does not work couse the enemy set look at the initial position of the player Node
then I tried the:
[java]
theenemy.setViewDirection(player.getLocalTranslation());
[/java]
I checked the node position with a hud text so I get the x, y & z correctly, them even change when the player node moves. (As you said It does not need a updateworldvectors() ) but, even if the position change, the enemy does not look at the player Node
That’s because you aren’t using either of those methods correctly. setViewDirection() will take a view direction and not a random location in the world. You’d have to turn it into a view direction first.
“upVector - a vector indicating the (local) up direction. (typically {0, 1, 0} in jME.)”
There are some 3D math and scene graph tutorials running around that you may want to run through. Without an understanding of the basic 3D concepts like direction vectors versus locations, your attempts to proceed will be just a bunch of random stabs in the dark, I think.
Well, you could have also passed UNIT_Y as the second lookAt() parameter instead of some random unrelated value… exactly as the javadoc says by the way.
In general, you will probably want to normalize the direction vector you create above or you will have problems later. Pretty sure the linked documentation talks about this if you ever get bored and want to read it.