Parallel camera with the map. 3rd person view

Hi guys,

I am working on a small project of beginners. I am try to build a 3rd person view game. In this case, I need to move a camera parallel with the map and not exceeds the map boundary. What should I do?

Thanks in advance.

For camera, set the camera to parallel projection: ‘cam.setParallelProjection(true);’

That will force the camera to view “top-down” - in the direction of negative Z - so x would be horizontal, y would be up and down, and z would be depth.

To force the camera to stay in the bounds, just check it’s location and compare it against your boundaries.

Also, just to answer your probable next question, you can set the zoom with this little snippet:

private void zoomCamera(float value){

        float h = cam.getFrustumTop();
        float w = cam.getFrustumRight();
        float aspect = w / h;

        float near = cam.getFrustumNear();

        float fovY = FastMath.atan(h / near)
                  / (FastMath.DEG_TO_RAD * .5f);
        fovY += value * 0.1f;

        h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near;
        w = h * aspect;