diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index 61eafcb..58f4a7b 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -1699,6 +1699,25 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 880679715} m_CullTransparentMesh: 1 +--- !u!1 &1105072965 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 6306269600238927148, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} + m_PrefabInstance: {fileID: 5796191506433166633} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1105072968 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1105072965} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 38fb1d450df272f49b06540bb0a4ab88, type: 3} + m_Name: + m_EditorClassIdentifier: + MinPitch: 0 + MaxPitch: 0 --- !u!4 &1194834060 stripped Transform: m_CorrespondingSourceObject: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} @@ -3770,6 +3789,14 @@ PrefabInstance: propertyPath: orthographic size value: 12.5 objectReference: {fileID: 0} + - target: {fileID: 1655227407111773373, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} + propertyPath: m_BindingMode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1655227407111773373, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} + propertyPath: m_AngularDampingMode + value: 0 + objectReference: {fileID: 0} - target: {fileID: 1873901299772310795, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_MinimumOrthoSize value: 12.5 @@ -3792,19 +3819,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3197454023887695364, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalRotation.w - value: 0.9979528 + value: 0.9979576 objectReference: {fileID: 0} - target: {fileID: 3197454023887695364, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalRotation.x - value: 0.0030935924 + value: 9.296001e-13 objectReference: {fileID: 0} - target: {fileID: 3197454023887695364, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalRotation.y - value: 0.06388009 + value: 0.06388041 objectReference: {fileID: 0} - target: {fileID: 3197454023887695364, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalRotation.z - value: -0.00019802434 + value: 1.4522473e-11 objectReference: {fileID: 0} - target: {fileID: 3401975006071930001, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_Targets.Array.data[0].radius @@ -3892,24 +3919,27 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8946450710138871461, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalRotation.w - value: 0.9979528 + value: 0.9979576 objectReference: {fileID: 0} - target: {fileID: 8946450710138871461, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalRotation.x - value: 0.0030935924 + value: 9.296001e-13 objectReference: {fileID: 0} - target: {fileID: 8946450710138871461, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalRotation.y - value: 0.06388009 + value: 0.06388041 objectReference: {fileID: 0} - target: {fileID: 8946450710138871461, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} propertyPath: m_LocalRotation.z - value: -0.00019802434 + value: 1.4522473e-11 objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 6306269600238927148, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} + insertIndex: -1 + addedObject: {fileID: 1105072968} m_SourcePrefab: {fileID: 100100000, guid: c53e6971c95afb1429cd82616a7b6737, type: 3} --- !u!1001 &7693964683212020007 PrefabInstance: diff --git a/Assets/Scripts/Extensions/ClampCameraRotation.cs b/Assets/Scripts/Extensions/ClampCameraRotation.cs new file mode 100644 index 0000000..c63d958 --- /dev/null +++ b/Assets/Scripts/Extensions/ClampCameraRotation.cs @@ -0,0 +1,26 @@ +using UnityEngine; +using Cinemachine; + +[AddComponentMenu("")] // Hide in menu - use extensions menu +[SaveDuringPlay] +[ExecuteAlways] +public class ClampCameraRotation : CinemachineExtension +{ + public float MinPitch = -20; + public float MaxPitch = 20; + + protected override void PostPipelineStageCallback( + CinemachineVirtualCameraBase vcam, + CinemachineCore.Stage stage, ref CameraState state, float deltaTime) + { + if (stage == CinemachineCore.Stage.Aim) + { + var rot = state.RawOrientation.eulerAngles; + rot.x = Mathf.Clamp(rot.x, MinPitch, MaxPitch); + rot.y = Mathf.Clamp(rot.y, MinPitch, MaxPitch); + rot.z = Mathf.Clamp(rot.z, MinPitch, MaxPitch); + state.RawOrientation = Quaternion.Euler(rot); + } + } +} + diff --git a/Assets/Scripts/Extensions/ClampCameraRotation.cs.meta b/Assets/Scripts/Extensions/ClampCameraRotation.cs.meta new file mode 100644 index 0000000..885f224 --- /dev/null +++ b/Assets/Scripts/Extensions/ClampCameraRotation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 38fb1d450df272f49b06540bb0a4ab88 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: