Node.updateWorldVectors() issue

Hi

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);

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

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

    theenemy.setJumpSpeed(20);
    theenemy.setFallSpeed(30);
    theenemy.setGravity(30);
    
    enemy = (Node) assetManager.loadModel("Models/runic/Cube.mesh.j3o");
    enemy.scale(0.8f);
    enemy.addControl(theenemy);
    rootNode.attachChild(enemy);
    
    bulletAppState.getPhysicsSpace().add(theenemy);

theenem.setPhysicsLocation(new Vector3f(65, 2, 0));
[/java]

And then in the simpleUpdate:

[java]

rootNode.updateWorldVectors();
theenemy.setViewDirection(player.getWorldTranslation());

[/java]

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:
[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.

And lookAt() does take a position as the first argument by the second argument is an “up vector” which the javadoc clearly says:
http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/Spatial.html#lookAt(com.jme3.math.Vector3f,%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:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3

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

Then you might specifically try these links from that page:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

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:

[java]
player.getWorldTranslation().substract(enemy.getWorldTranslation());
[/java]

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:

[java]
player.getWorldTranslation().substract(enemy.getWorldTranslation());
[/java]

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