How to set minimum and maximum camera angles?

Hi guys!

I have extended simple game and  been doing ok. But i have a problem that the camera can be moved upwards an infinite amount. I would like to set it so the camera will not go past y = 0.7. to this end I tired:


Vector3f cameraDirection = cam.getDirection();
if (cameraDirection.getY() >0.7f){
    cameraDirection.setY(0.7f);
    cam.setDirection(cameraDirection);
}


It does not do anything apart from make the camera jump to an upside down view after the camera has gone over the upper vertical limit.
any help will be much appreaciated

You're restricting the camera's direction, when it sounds like you mean to be restricting it's position?

If it is the direction that you mean to change, ie you want to limit how much it can rotate, then you should look at the rotations - you should not just change one component of a unit vector like that.

How do i limit how much the camera can rotate then?

I am not too hot with this vector stuff.

Any more help would be appreciated

:slight_smile: