First Person View Cam (FPVCam)

Hello everyone,

I spent some time searching for ways or libraries to move a camera with the WASD keys but i could never find something, until now… I didn’t want to reinvent the wheel, and since Peasycam is one of the most popular camera libraries that exists, i tried to add more functionality to it, and named it First Person View Cam (FPSVCam)

And it works! Most of the time… there’s still a bug with the movement when the look-at direction is almost parallel with an axis. Would someone accept the challenge to find the bug and squash it? I know where to start searching but i am not an expert in trigonometry so there is something failing there…

Besides key movement, another feature Peasycam already offers and i found super useful is saving camera positions and jumping between them with a delay and movement interpolation. But it doesn’t make sense to re-create these position every time you start a new sketch. So i created an option to save these positions to a JSON file.

I am keeping this in Alpha version until i find that bug in the movement, so the homepage is a bit improvised for now. Hopefully soon this will be ready to go full live :slight_smile:

Get the library here (examples and Javadoc included) or checkout the code on GitHub

PS: the bug is very likely to be after line 292, in the panning or rotation methods. Can you find it? :stuck_out_tongue:


You can fudge the camera location by adding a small amount so it will never be parallel. You may be getting a divide by zero error. This may be totally off-base.

Can you provide an example where the bug can be seen, and include the steps to reproduce the bug?

I think that’s a very good practice

On the other hand there is a library already called queasyCam

Indeed QueasyCam offers WASD controls, but only that. All other interesting functionality of PeasyCam is not there, like for example locking an axis or jumping between camera positions. Also its discontinued, and i can be wrong about this but i believe i did try Queasycam and it just didn’t work because it was not compatible with something else in my setup on current Processing version.

1 Like

Yeah, I just wanted to mention it.

I’d also like to see a Third Person View Camera, where the player can be shown in front of the camera, like Lara Croft in Tomb Raider


Hi Yousif, and others who could help me find the bug. I recorded another video, where the keys respond correctly in the 3 first camera positions, but then the fourth looking down (almost paralel to the Y axis) the movement is wrong. In the tests i did it seems only the Y axis is a problem, if the camera is paralel to X or Z the movement is as expected.

Could you take a quick look at the rotation methods, specially at the rotateX, rotateY and rotateZ to see if there is something that i missing?

When you initialize Peasycam or FPVCam, you can set the distance to the focus point, so that you can see more then just the point you are looking at. Second step would be to couple the movement of the camera with an object.

And that should give you a third person camera :slight_smile:

I am lost with this step

Sorry, that was a vague explanation. I am almost sure this is possible, to follow an object with the camera, but i haven’t tried it yet.

If you take a look at my PanCamera() method , line 297, you can see how to get the current LookAt point, and how to set a new one. Your lockAt point will be the “shoulder coordinate” (keep it simple during the first test and ignore rotations), and everytime the character moves, set the shoulder coordinate as the LookAt point, in the beginning of every draw.

I believe the camera should follow the character, while you can still look around with the mouse.

Let me know if it works

Thanks a ton!

Sounds awesome.

I’ll come back when I have a bit more time.

Thank you!


1 Like