LookAt or Move

Hi i have a problem with lookAt or at least think soo…
I have a model that moves by :

           getNodeBody().getLocalRotation().getRotationColumn(2).getZ()*(tpf*0.8f));// move

And has to look at by :

nodeBody.lookAt(new Vector3f(wayPoint.getX(), nodeBody.getLocalTranslation().getY(), 
 wayPoint.getY()),new Vector3f(0, 1, 0));

now look at is making my model look at it by right shoulder , while move with rotation column 2 is pretty perfect and makes it move where is pointed .
I dont know why this happens , i supposed that i have imported model , while it was rotated wrong , but why it moves forward with move method than ?
Well i dont know what might be wrong , all code is here, as i tested it separatelly on an TEST launcher ( extends SimpleApplication ), with only 2 models and this code in
public void simpleUpdate(float tpf) . and one model was running arround the other

PS my imported models are looking in direction of blue arrow in jme model opener

PS.PS i have used as well this code , for some minor rotattions

         nodeBody.rotate(0 , FastMath.DEG_TO_RAD*30, 0);

after i deleted it seems lookAt worked fine, now , is there a way to rotate a node , without breaking lookAt ?
if u use look at right ,and then at left ,it make no jokes, but after nodeBody.rotate(0 , FastMath.DEG_TO_RAD*30, 0);
it actually keep considering rotation in rotation column ,but not in look at

Move is already going to be moving relative to rotation… and then you are basing that move on the current rotation. That’s very strange.

What are you actually trying to do?

Edit: actually I’m mistaken. Move is not relative.

well i try to move an object forward by a lets say 1 distance * tpf .
thats why i use rotation column , to make it move right in X and in Z ,
while i dont need it to move in Y ,lats say its flat

Everyone always uses that strange rotation column magic and either does twice the work (like you are) or confuses themselves.

“I want to move in a direction relative to the spatial.” Then move in a direction relative to the spatial.

Vector3f dir = spatial.getLocalRotation().mult(someDir);

And if you don’t want to move in y then set dir.y to 0 first.

And I don’t see anything related to “looking at” anything in your code samples. Just a method call if distance is less than 0.15 in the x/z plane (done in a strange way).

Damn pasted wrong code !! 1 sec

Ok now its right

I actually do , its 0 in my code

…shouldn’t the be getZ()?

No , waypoint is Vector2f not 3f

after i deleted it seems lookAt worked fine, now , is there a way to rotate a node , without breaking lookAt ?

you can do “sub-node” for your special rotation and use lookAt for “main-node”, then nothing will be overriden, but ofc if “sub-node” will be for example rotated 90 degree, then lookAt for “main-node” will have “side as a front”. (same axis plain ofc)

about overall topic, im not sure what do you want to achieve.

lets say your “main-character-node” lookAt “1,0,0”, well you already know “front” of it, so you can do move in same direction via new location value in setLocalTranslation.

Otherwise you would need to know “start-front-vector” for model and transform it via rotation quaterion(the one generated from lookAt) to have “updated-front-vector”.

For simple example, you have front vector on start 1,0,0. You rotate 90 degree on Y axis, then you have 0,0,1 or 0,0,-1 whatever. to know this updated vector you need to use Transform object from Quaternion of this object, and pass there initial vector of 1,0,0 so it will just change it into 0,0,1 for example, and you then know front of your node, after rotation or lookAt methods.