First Person Camera
The first person camera in NeoFPS is a companion component for the Unity camera and adds a number of useful features for first person shooters.
Field of View
The NeoFPS camera adds additional functionality for controlling the field of view.
Firstly, it allows a horizontal field of view to be specified instead of the default vertical field of view. This is considered a standard in first person shooters, and a number of players will have their preferred FoV settings that they apply in and FPS games they play.
Secondly, it allows the field of view to be modified and animated using multipliers for zoom effects such as aiming down sights. You can modify and reset the FoV in your scripts using the following methods:
public void FirstPersonCamera.SetFov (float targetFovMult, float aimTime); public void FirstPersonCamera.ResetFov (float aimTime);
SetFov method takes an FoV multiplier that multiplies based on the standard field of view settings, along with an aim time that controls the duration of the animation from the existing FoV to the new FoV. The
ResetFov method takes the same aim time parameter which controls how long it takes to return to the standard field of view settings.
The camera offset is a position and rotation offset that can be applied and removed to move and animate the camera within the hierarchy. An example use is the modular firearms' HeadMoveAimer which actually moves the head down to the weapon instead of the weapon up to the camera. This allows a lean angle to be added and for the camera rotation to be modified making for an interesting aim effect. You can modify and reset the offset in scripts using the following methods:
public void FirstPersonCamera.SetOffset (Vector3 posOffset, Quaternion rotOffset, float aimTime); public void FirstPersonCamera.ResetOffset (float aimTime);
These methods take offset parameters, along with an aim time parameter that controls how long it takes to reach the offset and return.
The first person camera also contains the following event:
public static event FirstPersonCamera.UnityAction<FirstPersonCamera> onCurrentCameraChanged;
Subscribing to this event will notify when the camera changes (when it is being looked through or not). This can be used for things such as enabling a scene or spectator camera if the player dies.