Hey everyone!
I’m struggling a bit with figuring out how to prevent players with more extreme aspect ratios from seeing farther than other players. The game is top down, so being able to see farther than another player is a significant advantage.
I have this box right here which represents the maximum distance I want players to be able to see.
Does anyone know how to fix this? I’m guessing it has something to do with field of view, but I couldn’t actually figure out an algorithm to make it work.
Still not sure on how to accomplish this, but after giving it some more thought it may be possible to find a workaround if anyone knows how to force the camera to have a certain part in one of it’s corners (By having the camera move, not by moving the part such as with viewportpointtoray).
If anyone knows how to do this, I may be able to find a solution by simply interpolating between the 4 corners of the screen’s “view space”.
I guess you could use a frame on all sides that only appears if the viewport size is not of the correct aspect ratio, preventing visibility beyond what you want
Okay so, by setting the FieldOfViewMode to MaxAxis, it prevents the player from seeing outside of the box when changing their aspect ratio. The downside is that unless your game has an aspect ratio of 1:1, a side of your screen will get cut off. This can be solved by having the player’s crosshair move the camera along the axis that was truncated.
For instance, if a player has a 1000x500 screen resolution, they could see the top half of the screen by moving their cursor to the top of the screen, and the bottom half by moving it to the bottom of the screen.
Okay, it’s not 100% perfect (even though it should be mathematically sound? who knows) but it works for the most part. The big downside seems to come from the fact that it doesn’t work when the aspect ratio goes under 1. This is as a result of setting the camera mode to maxaxis, meaning the FieldOfView won’t go beyond MaxAxisFieldOfView (which occurs when ViewportSize.Y is equal or higher to ViewportSize.X.
So here’s another question: Is it possible, based on the ViewportSize, to determine what the FieldOfView would be set to if it could go beyond MaxAxisFieldOfView? This should allow us to make this work on vertical resolutions as well.