aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assets/Prefabs/Camera.prefab16
-rw-r--r--Assets/Scripts/CameraFOVBinding.cs25
-rw-r--r--Assets/Scripts/CameraFOVBinding.cs.meta11
3 files changed, 52 insertions, 0 deletions
diff --git a/Assets/Prefabs/Camera.prefab b/Assets/Prefabs/Camera.prefab
index 453dae2..436a263 100644
--- a/Assets/Prefabs/Camera.prefab
+++ b/Assets/Prefabs/Camera.prefab
@@ -147,6 +147,7 @@ GameObject:
m_Component:
- component: {fileID: 4026152251359113875}
- component: {fileID: 2366565221016314013}
+ - component: {fileID: 8139774841432166366}
m_Layer: 10
m_Name: Camera
m_TagString: Untagged
@@ -196,6 +197,21 @@ MonoBehaviour:
m_Bits: 1
cameraCollisionOffSet: 0.2
minimumCollisionOffSet: 0.2
+--- !u!114 &8139774841432166366
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2437604724584673593}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 01e207a32ce88164f9563034ae06f0d8, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ camera: {fileID: 2643216581844201031}
+ normalFOV: 75
+ runningFOV: 95
--- !u!1 &7048044712634968914
GameObject:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/CameraFOVBinding.cs b/Assets/Scripts/CameraFOVBinding.cs
new file mode 100644
index 0000000..1275fe8
--- /dev/null
+++ b/Assets/Scripts/CameraFOVBinding.cs
@@ -0,0 +1,25 @@
+using System;
+using DS;
+using UnityEngine;
+
+[RequireComponent(typeof(CameraHandler))]
+public class CameraFOVBinding : MonoBehaviour
+{
+ public Camera camera;
+ public float normalFOV;
+ public float runningFOV;
+ private CameraHandler _cameraHandler;
+ private PlayerLocomotion _playerLocomotion;
+
+ private void Start()
+ {
+ _cameraHandler = GetComponent<CameraHandler>();
+ _playerLocomotion = _cameraHandler.player.gameObject.GetComponent<PlayerLocomotion>();
+ }
+
+ private void FixedUpdate()
+ {
+ var targetFOV = _playerLocomotion.isSprinting ? runningFOV : normalFOV;
+ camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, targetFOV, 0.12f);
+ }
+}
diff --git a/Assets/Scripts/CameraFOVBinding.cs.meta b/Assets/Scripts/CameraFOVBinding.cs.meta
new file mode 100644
index 0000000..3de5aa7
--- /dev/null
+++ b/Assets/Scripts/CameraFOVBinding.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 01e207a32ce88164f9563034ae06f0d8
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: