LibGDX Problems when using an Orthographic Camera and Bullet

Hi everyone. As you can see this is my first post on here. I’ve lurked for a while now and I’ve decided to join the community.

I’m still inexperienced with LibGDX and i’m working on developing my first 3D project. I’m having issues when using an Orthographic Camera, hit detection with the Camera Ray and Bullet collision detection. I’ve been struggling on this for a while and i can’t find a solution. When i have the Camera positioned at (5, 5, 10) the RayCallback works perfectly. I can click on the objects and a hit is registered inside the TouchDown code. However, when i pan around the map i get this camera clipping effect which cuts out the lower area of map which i am trying to view.

Here is a preview of the RayCallback detecting hits on the objects.

I have tried changing the Camera position to make it much further out (such as 50,50,50 or 100,100,100) and also changing the Camera.near/Camera.far values. This fixes the map clipping issue and the view of the map looks exactly the same, but it causes my hit detection on my RayCallback to stop detecting anything. I don’t understand why it works at 5,5,10 and not 100,100,100?

Here is a preview of a Camera which i have positioned at 50,50,50 no longer clipping the map but the hit detection has stopped working

Alternatively i have tried using a different RayCallback using this code;

    public int getObject (int screenX, int screenY) {
        Ray ray = cam.getPickRay(screenX, screenY);
        int result = -1;
        float distance = -1;
        for (int i = 0; i < instances.size; ++i) {
            final GameObject instance = instances.get(i);
            instance.transform.getTranslation(position);
            position.add(instance.center);
            float dist2 = ray.origin.dst2(position);
            if (distance >= 0f && dist2 > distance) continue;
            if (Intersector.intersectRaySphere(ray, position, instance.radius, null)) {
                result = i;
                distance = dist2;
            }
        }
        return result;
    }

Like the RayCallback code, It works at 5,5,10 but instead of not working at 50,50,50 - it fills the entire world map. I receive a hit no matter where i click on the screen.

I don’t normally ask for help because i can find the answers to most of my questions through a quick google search. Apologies if this question has been asked before - i can’t find anything on it.

You can view my full code here.