CameraNode lookAt Problem

Hey Guys,

we are currently working on a project for university and decided to use jme3 for our game.

Its a kind of 2D Top-Down Adventure and we just set up a demoLevel to try out jme3, containing a little room, a player controlled through WASD and a y-axis-rotation looking at the current position of the mouse, the typical setting for this genre.

Even collision and some lighting already works fine.

There is also a CameraNode following and looking topDown at a Node that contains the geoms for the player character.

I just followed the very well explained tutorials and everything worked fine.

Now we started to create the architecture of the game using AppStates.

There are different States, one of them is GameRunningState, which contains most of the stuff from our demoLevel.

Again everything works fine, expect the cameraNode. It moves correctly with the playerNode, but it does not look topdown like before.

It seems as if there is some kind of weird rotation at the z-axis or if lookAt focuses some point in the distance!

Here is the code for my camera (its nearlly identically to the code from the tutorial:)


private void initCamera() {


camNode = new CameraNode("Camera Node", viewPort.getCamera());



camNode.setLocalTranslation(new Vector3f(0, 60, 0));

camNode.lookAt(playerPivot.getLocalTranslation(), Vector3f.UNIT_Y);


Can anybody help me with my problem?

Howabout just doing this:

[java]camNode.setLocalTranslation(new Vector3f(0, 60, 0));

camNode.lookAt(new Vector3f(0, 0, 0),Vector3f.UNIT_Y);[/java]

You might be changing the location of the playerPivot so if you do this, then it will keep still.

If it doesn’t work, then you might be editing this during updates and need to post that code aswell…

1 Like

Hey Addez,

thx for your fast reply!

One reason for choosing jmonkey is the very active community and it really was a good decision!

Thank god you mentioned the update method, that solved my problem! xD

I was trying to rotate the collision shape of the character just before we started to work with the architecture,

so there was a line of code left in the update-method:

[java]player.setViewDirection(new Vector3f(playerRotation.getX(), 0, playerRotation.getZ()));[/java]

(player is my characterControl)

i just deleted this line and now the camera is working again!