Added weapon zoom
This commit is contained in:
parent
740e61c97a
commit
533761ca1c
|
@ -3683,6 +3683,27 @@ Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 8762286023885395322, guid: 9c489a8547f4d9e4387da15a4ff82c81, type: 3}
|
m_CorrespondingSourceObject: {fileID: 8762286023885395322, guid: 9c489a8547f4d9e4387da15a4ff82c81, type: 3}
|
||||||
m_PrefabInstance: {fileID: 6782772648210504087}
|
m_PrefabInstance: {fileID: 6782772648210504087}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1 &1859157918 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 8616685848737228372, guid: c5efc39a8aaf6e64ea40e9ad573e9b47, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 8204767108263278737}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &1859157931
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1859157918}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: f6b8a4e9bfb741aa96889e5df5a06cba, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_fovNormal: 40
|
||||||
|
_fovZoom: 20
|
||||||
|
_camera: {fileID: 1874573760}
|
||||||
|
_zoomedIn: 0
|
||||||
--- !u!20 &1874573760 stripped
|
--- !u!20 &1874573760 stripped
|
||||||
Camera:
|
Camera:
|
||||||
m_CorrespondingSourceObject: {fileID: 9005220659476430821, guid: 2d3a85ecde41a8246a79669975912b74, type: 3}
|
m_CorrespondingSourceObject: {fileID: 9005220659476430821, guid: 2d3a85ecde41a8246a79669975912b74, type: 3}
|
||||||
|
@ -4029,6 +4050,10 @@ PrefabInstance:
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9005220659476430821, guid: 2d3a85ecde41a8246a79669975912b74, type: 3}
|
||||||
|
propertyPath: field of view
|
||||||
|
value: 40
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 9005220659476430821, guid: 2d3a85ecde41a8246a79669975912b74, type: 3}
|
- target: {fileID: 9005220659476430821, guid: 2d3a85ecde41a8246a79669975912b74, type: 3}
|
||||||
propertyPath: far clip plane
|
propertyPath: far clip plane
|
||||||
value: 500
|
value: 500
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
using Cinemachine;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
using Debug = System.Diagnostics.Debug;
|
||||||
|
|
||||||
|
public class WeaponZoom : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Header("Configuration")]
|
||||||
|
[SerializeField] private float _fovNormal;
|
||||||
|
[SerializeField] private float _fovZoom;
|
||||||
|
[Header("State")]
|
||||||
|
[SerializeField] private CinemachineVirtualCamera _camera;
|
||||||
|
[SerializeField] private bool _zoomedIn;
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
_camera = FindObjectOfType<CinemachineVirtualCamera>();
|
||||||
|
Debug.Assert(_camera != null, nameof(_camera) + " != null");
|
||||||
|
_fovNormal = _camera.m_Lens.FieldOfView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (Mouse.current.rightButton.wasPressedThisFrame)
|
||||||
|
{
|
||||||
|
_zoomedIn = !_zoomedIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_zoomedIn)
|
||||||
|
{
|
||||||
|
_camera.m_Lens.FieldOfView = _fovZoom;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_camera.m_Lens.FieldOfView = _fovNormal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f6b8a4e9bfb741aa96889e5df5a06cba
|
||||||
|
timeCreated: 1665776026
|
Loading…
Reference in New Issue