init: version 1
This commit is contained in:
145
Assets/Prefabs/Camera/Camera.prefab
Normal file
145
Assets/Prefabs/Camera/Camera.prefab
Normal file
@@ -0,0 +1,145 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8972490550095723796
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5544766781807189859}
|
||||
- component: {fileID: 7050825736911644692}
|
||||
- component: {fileID: 5054482749786690855}
|
||||
- component: {fileID: 6165980040932047043}
|
||||
m_Layer: 0
|
||||
m_Name: Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5544766781807189859
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8972490550095723796}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 2, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!20 &7050825736911644692
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8972490550095723796}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 2
|
||||
m_BackGroundColor: {r: 1, g: 1, b: 1, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 34
|
||||
orthographic: 1
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 0
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 0
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 0
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!114 &5054482749786690855
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8972490550095723796}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_RenderShadows: 1
|
||||
m_RequiresDepthTextureOption: 2
|
||||
m_RequiresOpaqueTextureOption: 2
|
||||
m_CameraType: 0
|
||||
m_Cameras: []
|
||||
m_RendererIndex: -1
|
||||
m_VolumeLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 1
|
||||
m_VolumeTrigger: {fileID: 0}
|
||||
m_VolumeFrameworkUpdateModeOption: 2
|
||||
m_RenderPostProcessing: 1
|
||||
m_Antialiasing: 2
|
||||
m_AntialiasingQuality: 2
|
||||
m_StopNaN: 0
|
||||
m_Dithering: 0
|
||||
m_ClearDepth: 1
|
||||
m_AllowXRRendering: 1
|
||||
m_AllowHDROutput: 1
|
||||
m_UseScreenCoordOverride: 0
|
||||
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_RequiresDepthTexture: 0
|
||||
m_RequiresColorTexture: 0
|
||||
m_Version: 2
|
||||
m_TaaSettings:
|
||||
m_Quality: 3
|
||||
m_FrameInfluence: 0.1
|
||||
m_JitterScale: 1
|
||||
m_MipBias: 0
|
||||
m_VarianceClampScale: 0.9
|
||||
m_ContrastAdaptiveSharpening: 0
|
||||
--- !u!114 &6165980040932047043
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8972490550095723796}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0021af939cbccbc12893bf16fb51dc4d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
smoothTime: 0.15
|
||||
offset: {x: 0, y: 1, z: -10}
|
||||
7
Assets/Prefabs/Camera/Camera.prefab.meta
Normal file
7
Assets/Prefabs/Camera/Camera.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97eb29a48aa9550f3b89acd87c95d234
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Prefabs/Camera/Scripts.meta
Normal file
8
Assets/Prefabs/Camera/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 316043dde95a08cbf90930192d59aa6e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
Assets/Prefabs/Camera/Scripts/CameraController.cs
Normal file
61
Assets/Prefabs/Camera/Scripts/CameraController.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// CameraController lets the camera follow the player smoothly.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class CameraController : MonoBehaviour
|
||||
{
|
||||
[Header("Configuration")]
|
||||
public float smoothTime = 0.15f;
|
||||
public Vector3 offset = new (0f, 1f, -10f);
|
||||
|
||||
private GameObject _player;
|
||||
private Vector3 _velocity;
|
||||
private Vector3 _mapSwitchOffset;
|
||||
private bool _respawned;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_player = GameObject.FindWithTag("Player");
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (_mapSwitchOffset != Vector3.zero)
|
||||
{
|
||||
// When switching maps, teleport the camera to the new position.
|
||||
transform.position += _mapSwitchOffset;
|
||||
_mapSwitchOffset = Vector2.zero;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_respawned)
|
||||
{
|
||||
// If the player has respawned, teleport the camera to the new position.
|
||||
transform.position = _player.transform.position + offset;
|
||||
_respawned = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 targetPosition = _player.transform.position + offset;
|
||||
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _velocity, smoothTime);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
GameManager manager = GameManager.Instance;
|
||||
manager.onMapSwitch.AddListener(OnMapSwitch);
|
||||
manager.onRespawn.AddListener(OnRespawn);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
GameManager manager = GameManager.Instance;
|
||||
manager.onMapSwitch.RemoveListener(OnMapSwitch);
|
||||
manager.onRespawn.RemoveListener(OnRespawn);
|
||||
}
|
||||
|
||||
private void OnMapSwitch(int idx, Vector3 o) => _mapSwitchOffset = o;
|
||||
private void OnRespawn() => _respawned = true;
|
||||
}
|
||||
2
Assets/Prefabs/Camera/Scripts/CameraController.cs.meta
Normal file
2
Assets/Prefabs/Camera/Scripts/CameraController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0021af939cbccbc12893bf16fb51dc4d
|
||||
Reference in New Issue
Block a user