Chase Cam question

I’ve implemented the chase cam from the tutorial:

I’m trying to figure out how to edit it such that one can change the height from which the camera looks at. I’ve set up an analog binding that rotates left and right so I added a rotate up and down that adds or subtracts from a defined Y variable.

if (binding.equals(“rotateRight”)) {tPlayer.playerModel.rotate(0, valuetpf50, 0);}

if (binding.equals(“rotateLeft”)) {tPlayer.playerModel.rotate(0, valuetpf-50, 0);}

if (binding.equals(“rotateUp”)) {chaseCamY -= valuetpf50;}

if (binding.equals(“rotateDown”)) {chaseCamY -= valuetpf-50;}

When I edit the code to incorporate it, it moves the camera up and down, as it should:

camNode.setLocalTranslation(new Vector3f(0,chaseCamY,-5));

However when I try to get the camera to look at where the player is, the rotate left and right no longer rotate around the character at the center.

camNode.lookAt(tPlayer.playerModel.getLocalTranslation(), Vector3f.UNIT_Y);

I’m not sure if I’m describing this properly… I hope this makes sense. :slight_smile:

I’ll admit I didn’t understand much of what you wrote, but I do know that lookAt needs WORLD coordinates, not local.

The javadoc is your friend…

1 Like

The Javadoc at times can be rather sparse in descriptions. Don’t get me wrong though, I have the javadoc bookmarked and have been reading it the best I can, there are just some gaps that I don’t understand.

When I change lookAt to to playerModel.getWorldTranslation(), it does the same thing.

Hmm, I’ll try to clarify what I want instead of what’s happening, maybe I don’t understand how lookAt works. Basically, I’m trying to make a dynamic camera from which you can edit the height of the camera and it’ll adjust the pitch of the camera to always be pointing at the character.