FOV override
FOV is the field of view: how wide the camera’s view is, in degrees. The override is also how you make a zoom.
ScreenFx the field of view override
ScreenFx.SetFovOverride sets the camera’s field of view in degrees, and ClearFovOverride gives the player’s own value back. This is how you make a zoom.
public static bool SetFovOverride(float fov);
public static bool ClearFovOverride();
public static bool SetFovOverride(string owner, float fov);
public static bool ClearFovOverride(string owner);
| Method | Returns | What it does |
|---|---|---|
SetFovOverride(fov) | bool | Sets the field of view, with no owner. |
ClearFovOverride() | bool | Removes that value. |
SetFovOverride(owner, fov) | bool | Sets the field of view, as your mod. |
ClearFovOverride(owner) | bool | Removes your value. |
Things to know
SetFovOverridesets how wide the view is, in degrees, and keeps it there until you clear it. A small number zooms in. It returnstruewhen the value was stored andfalsewhenIsAvailableisfalse.ClearFovOverridebrings back the player’s own field of view. It returnstruewhen it removed a value andfalsewhen none was set. The view goes back on the next frame. (On the next frameSetCameraFOV.Updatefinds the camera different fromDisplaySave.fovand writes the saved FOV back.)- The player’s saved field of view and the options screen are not changed. The override is only in memory and is not saved. (
DisplaySaveis never written.) - A normal level load clears the override, but loading extra scenes in the background does not. The clear happens before your
Events.SceneLoadedhandler runs, so a handler that sets it keeps it. Opening or closing a menu does not clear it either, so it stays through the pause menu. (Only a Single scene load clears it, so an additive streaming load keeps it.) - The override applies to every camera the game gives a field of view. If the framework’s change to the game’s camera code throws an error, it is logged once and the game’s own code runs for that frame. (Every camera with a
SetCameraFOVcomponent.) - With an
owner, each mod has its own value, so two mods don’t overwrite each other silently. The value set last is the one shown. When that mod clears its value, the value set before it shows again. Without anowner, the calls use one shared value of their own, and they never remove a mod’s value. - A normal level load clears every value.
SetFovOverridealso works insideEvents.SceneLoadedand while a save is loading or being written. - This is the zoom feature. A zoom key calls
SetFovOverride(owner, fov)when pressed andClearFovOverride(owner)when let go, as the quick example does. The Player page has the camera. (SetCameraFOV.UpdatewritesfieldOfViewonly when it differs fromDisplaySave.fov, andSetFOValways writes it. The framework’s prefix returnsfalsewhile an override is set, so the game’s write does not run and the override holds.)
Limits
- A number below 30 is changed to 30, and a number above 120 is changed to 120. A value that is not a real number throws an
ArgumentException. (The limits are not taken from the game’s settings slider, because the slider’s minimum and maximum are set in the Unity editor and are not in the game code.) - While an override is set, the Field of View slider in the options menu looks as if it does nothing. The slider still changes the saved value, but the camera does not follow it until the override is cleared or a level loads. (
SetCameraFOV.Updateis skipped while an override is set.) - The game’s radiation check uses the player’s saved view while an override is set. (
RadiationEffectUIpasses the savedDisplaySave.fovtoRadiationController.LookingAtRadiation, not the camera field of view.)