'Orbit camera.target around center (raylib 3d)

    lastMouse = mouse;
    mouse = GetMousePosition();
    changeMouse = {lastMouse.x - mouse.x, lastMouse.y - mouse.y};

    angleXZ += changeMouse.x*DEG2RAD/2;
    angleY += changeMouse.y*DEG2RAD/2;
    
    vecXZ = Angle2Vector(angleXZ);
    vecY = sinf(angleY);

    camera.target.x = vecXZ.x+camera.position.x;
    camera.target.z = vecXZ.y+camera.position.z;
    camera.target.y = vecY+camera.position.y;

Im using a 3d game library (raylib), the camera is always facing the camera.target.

Looking left and right work perfectly however up and down does not.

I know i have to add something else to X and Z to make sure Y orbits correctly but im not sure what that is?

Can someone help me out (NOTE: code is in game update loop)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source