Node.updateWorldVectors() issue


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

CapsuleCollisionShape pcs = new CapsuleCollisionShape(2f, 4f, 1);
theplayer = new CharacterControl(pcs, 0.01f);

    player = (Node) assetManager.loadModel("Models/garret/Cube.mesh.j3o");

theplayer.setPhysicsLocation(new Vector3f(60, 2, 0));

CapsuleCollisionShape ecs = new CapsuleCollisionShape(1.5f, 0.1f);
theenemy = new CharacterControl(ecs, 0.01f);

    enemy = (Node) assetManager.loadModel("Models/runic/Cube.mesh.j3o");

theenem.setPhysicsLocation(new Vector3f(65, 2, 0));

And then in the simpleUpdate:




Any help will be appreciated.

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:
lookAt(player.getLocalTranslation(), enemy.getLocalTranslation());
It really does not work couse the enemy set look at the initial position of the player Node
then I tried the:

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.

And lookAt() does take a position as the first argument by the second argument is an “up vector” which the javadoc clearly says:,%20com.jme3.math.Vector3f)

“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.

This page will be your best friend:

If you haven’t gone through the tutorials then do so… all of them.

Then you might specifically try these links from that page:

They are good primers on the very basics you will need to know to develop a 3D game.

Ok thanks, I solved it, installing the latest version and trying again the:


that was the “big deal”.

But thanks for answering =D

@RemEnemy23 said: Ok thanks, I solved it, installing the latest version and trying again the:


that was the “big deal”.

But thanks for answering =D

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.

I’m reading, I guess everything in the simple math presentation will help me in some way =D