I know this may sound like a stupid question. But I’ve always tried to stay away from using the standard FPS Controller script, mostly because of how difficult it would be to implement new features into that. So I never saw this.
Just now I decided to import only the controller, and some other essential scripts. And one of the things I unselected said “FOVkick”, now I know what “FOV” stands for (field of view). But I don’t know what the “kick” part means.
Because in the FPSController component, I have an option called “Use FOV kick”, and now I’m curious.
Can anyone tell me what it is?
1 Like
FOVKick is a script attached to the camera, aiming at increasing the player’s field of view when he’s running and decreasing it when he gets back to walking:
using System;
using System.Collections;
using UnityEngine;
namespace UnityStandardAssets.Utility
{
[Serializable]
public class FOVKick
{
public Camera Camera; // optional camera setup, if null the main camera will be used
[HideInInspector] public float originalFov; // the original fov
public float FOVIncrease = 3f; // the amount the field of view increases when going into a run
public float TimeToIncrease = 1f; // the amount of time the field of view will increase over
public float TimeToDecrease = 1f; // the amount of time the field of view will take to return to its original size
public AnimationCurve IncreaseCurve;
public void Setup(Camera camera)
{
CheckStatus(camera);
Camera = camera;
originalFov = camera.fieldOfView;
}
private void CheckStatus(Camera camera)
{
if (camera == null)
{
throw new Exception("FOVKick camera is null, please supply the camera to the constructor");
}
if (IncreaseCurve == null)
{
throw new Exception(
"FOVKick Increase curve is null, please define the curve for the field of view kicks");
}
}
public void ChangeCamera(Camera camera)
{
Camera = camera;
}
public IEnumerator FOVKickUp()
{
float t = Mathf.Abs((Camera.fieldOfView - originalFov)/FOVIncrease);
while (t < TimeToIncrease)
{
Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t/TimeToIncrease)*FOVIncrease);
t += Time.deltaTime;
yield return new WaitForEndOfFrame();
}
}
public IEnumerator FOVKickDown()
{
float t = Mathf.Abs((Camera.fieldOfView - originalFov)/FOVIncrease);
while (t > 0)
{
Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t/TimeToDecrease)*FOVIncrease);
t -= Time.deltaTime;
yield return new WaitForEndOfFrame();
}
//make sure that fov returns to the original size
Camera.fieldOfView = originalFov;
}
}
}
6 Likes
I mean…what’s stopping you from turning it on and seeing what it does? Not to mention that the standard stuff gets imported as source so you could just go look at the code…
In either case - it modifies the field of view of the camera when you “sprint”.
2 Likes
aka, the Alfred Hitchcock effect.
1 Like
Thank you everyone for your kind and non sarcastic answers. 
2 Likes