Camera positioning birds eye

Hello, its my first post. i started dev with jMonkey few days ago, and creating my own game… I encountered a problem with camera positioning. i want to set camera at top of the world. seems like in the GTA1 and GTA2 camera…

should i create CameraNode and add it to player node? how to update this camera location and how to setDirection to player? how i can be always at the top of the player?

If you want a top bird’s eye perspective, you can set the x and z values of the camera to the x and z values of the player. You can do that inside the update() method regularly. For the y value you can choose which height your cam you want to be.

Such as:
cam.setLocation(new Vector3f( player.getLocalTranslation().x, camHeight, player.getLocalTranslation().z));

Attaching it to the player may work too, but then the camera tilts and goes up and down with the player.

If you want to only rotate the camera with the player too, I percept doing the same with rotation instead of translation should do the trick.

ok, but, first.

1. this.cameraNode = new CameraNode(CommonValues.CAMERAMANAGER_CAMERA_NODE_NAME, camera);
2. this.cameraNode.setControlDir(ControlDirection.SpatialToCamera);
3. this.playerNode.attachChild(this.cameraNode);
4. playerNode.attachChild(spatial);

and, where i should update cam location, and when i moving player should i use spatial.move function? or setLocalTranslation?

setLocalTranslation() sets the direct coordinates for a spatial. move() moves it relative to its current position. E.g. setLocalTranslation(5,0,0); moves it to 5,0,0. But if it is at the position 3,0,0 and you apply move(5,0,0); to it, it will land on the coordinates 8,0,0.

Eeeh, if you attach your camera to the player, it will automatically move with the player. But, it will perform every translation the player does. If you want this, it’s fine.

If you want to go the other solution, you would attach the camera to the rootNode. Then, in the update() method, you apply the coordinates.

Which update() method to choose really depends on your game structure. Do you still have only the main class or is that code in an AppState? Controls are also a choice. There is always one dedicated update() method.

At my app i have few classes and engines related to each functionality, like cameraManager heroManager nodeManager, but with appstate didnt create anything, still using extending simpleapplication

Relating to objext, ok i undersatand that move method also moving local translation?

Next question, adding cameraNode to rootNode and change camera location depending on player geometry? Node? is good choice?

And whats a impact on camera and camera node? There are two different locations?
The same with player geometry and player node, there are two different localtranslations

Sorry for my questions, im so frustrated, spent 5 hours for this camera :frowning:

Ok, here a more expertized person has to answer.

I know what a Node and a Geometry in general is. Typically you use Nodes to organize your Geometries in your Scene Tree. Because, you can attach something to a Node, but you cannot attach something to a Geometry. So in general multiple Geometries are attached to one Node, to be stitched together in their movements.

Because of that, if the camera is attached to the cameraNode, and the player is attached to the playerNode, it doesn’t matter if you transform the Nodes, because the attached Geometries move with them.

Maybe that helps to understand the behaviour of Nodes and Geometries. I don’t know what the special cameraNode or playerNode is though, so if that matters someone that knows has to answer.

Maybe try the chase camera. There you can set the spatial/node you want to follow. There are a lot of parameters to define how the chase camera shall follow your spatial.
In the past I did it with a control to make the camera follow if I needed a special camera and not the chase camera. To day I switched to ECS and do the camera update in that way.

public CameraManager(Camera camera, InputManager inputManager) { = camera;;
    this.chaseCamera = new ChaseCamera(, inputManager);


public void setSpatialFollow(Spatial spatial) {

this is my code, and still i cant see anything, but i should see 2 boxes

im not begining developer, but im so frustrated of this camera :confused:

I suggest to post your code so we can see what you do. Some pointers:

I would go from something working.

yes i know, = new Box(size.getX(), size.getY(), size.getZ());
    this.geometry = new Geometry(geometryName,;
    this.material = new Material(assetManager, CommonValues.HEROGEOMETRY_DEFAULT_MATERIAL);
    this.material.setColor("Color", color);

this is my box, i can see it at default camera, but i dont know how to change position and focus

i was trying with both, camera node and chase camera :confused:

Hmmmm if you set the chase camera to this box the chase camera follows automatically your box. Further more you can orbit around your box.
Can you maybe make one single class example and post the code, I guess you will find one who can help. I currently have no computer in range to try it… but yeah post a complete runnable example.

Until now I’ve used that code to chase my geometry:

        // Disable the default flyby cam
        // Enable a chase cam for this target (typically the player).
        ChaseCamera chaseCam = new ChaseCamera(cam, gBox1, inputManager);

Now I’ve used your code:

        // Disable the default flyby cam
        // Enable a chase cam for this target (typically the player).
        ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);    

The difference: In the first example the target is specified in the constructor. In the second example the target is added afterwards by .setSpatial()

The result: First code works. With the second one, I also see nothing any more.

Let’s see what the documentation for .setSpatial() says:
Sets the spacial for the camera control, should only be used internally.
So, maybe the method isn’t meant to be used the way you want. Only if I specify the target in the constructor it works (new ChaseCamera(cam, gBox1, inputManager)).

ok, i fixed my problem but… always but:

my trace:

  1. I create camera node
    this.cameraNode = new CameraNode(CommonValues.CAMERAMANAGER_CAMERA_NODE_NAME,;
  1. I add this camera node to playersnode


  1. and now, i have to change camera location, and set this camera above the box


everything should be good, but i have invertex axes :confused: when i move left on that camera box moxe right…

public void moveLeft(float tpf) {
    float offset = tpf * getMovementSpeed();
public void moveRight(float tpf) {
    float offset = tpf * getMovementSpeed();
public void moveUp(float tpf) {
    float offset = tpf * getMovementSpeed();
public void moveDown(float tpf) {
    float offset = tpf * getMovementSpeed();

i had to add on my func camera rotation:

public void updatePositionAndFocus(Vector3f position) {
    Quaternion roll180 = new Quaternion();
    roll180.fromAngleAxis(FastMath.PI, new Vector3f(0, 0, 1));
    cameraNode.lookAt(position, new Vector3f(0, 0, 0));

all of this rotation for now, i had to have in this updating camera position :confused: any ideas? :worried: