Since I’m making a FNaF remake game, the screen will turn as you move your cursor, like in the games, until it reaches it’s “Range,” which is just the farthest it can turn (I have it at 20 degrees).
The problem is, depending on the screen, the player might not be able to see the vent on their right side, and sometimes they could see too far ahead. This is hard to control because it’s completely based on their screen size.
Here’s a visual example:
Notice how depending on their screen, they may not be able to see a crucial part of the game?
One idea I had was WorldToScreenPoint, I tried but it didn’t really work how I intended.
Add an invisible wall after each vent, or record the position. When the camera Z (or whatever angle is rotating left/right) passes that point, set it back to that Z point.
Hopefully that makes sense. Old games used to be coded this way for 2D wall detection; rather than the wall preventing the sprite with physics, it was prevented by returned it to its respective position when it passed the wall (while still allowing movement parallel to the wall).
Edit: you can incorporate WorldToScreenPoint here, once the “wall” is onscreen, the camera need not continue.
then if you divide 42° by 1.7777 you get 23.6° which is very close to 25°
So basically 42 (the max angle) divided by the aspect ratio should be pretty close to what you need.
That means a wider 20:9 phone screen would see 42 / 2.2222 = 18.9° as well.
I think another way to do it is just change the players FieldOfView depending on their device aspect ratio. This way the same 20° limit either direction with different FOV could give the same edge limits of the player’s view.