Wrong rotation in using LookAt() method [solved]

I’m using navmesh pathfinder to find the path and Waypoint position in look at method. but it rotates wrong.

my code in update method:

       if (!npf.isAtGoalWaypoint()) {

                    npf.goToNextWaypoint();
                    Vector3f pos = npf.getNextWaypoint().getPosition();
                    tank.lookAt(Vector3f.UNIT_Y, pos);
                    tank.setLocalTranslation(pos);

                }

Untitled

Your Code is wrong obviously, I guess it’s just the order:
tank.lookAt(pos, Vector3f.UNIT_Y) should do the trick (sometimes the UP Vector is still a bit problematic)
And btw there also is tank.lookAtDirection(), not that it would be much relevant here.

1 Like

thank you so much, I replaced up vector and pos. it works!

1 Like