Limit camera on the horizontal axis

Hello,



What I'am trying to accomplish is limit the camera in it's rotation to the left and the right.

My math is not that strong , this is why i can't figure out how this works.



I found some information on the forum to max the up and down and implementated it succesfully.

But to the left and right i can't figure out.



Can anybody explain this to me, Thank you


  • I create a RotateHorRestricted(KeyInputAction),
  • Then try to calculate the angle

If anybody ever seems to struggle with the same issue here is the solution which works for me: