From d418535a7b664a726760ecb41538fd24b2ef2a9e Mon Sep 17 00:00:00 2001 From: Scove <104053980+Scove-Metalreal@users.noreply.github.com> Date: Fri, 27 Mar 2026 12:08:16 +0700 Subject: [PATCH] Update --- .idea/.idea.HALLUCINATE/.idea/workspace.xml | 29 +- Assets/InputSystem_Actions.inputactions | 49 ++- Assets/InputSystem_Actions.inputactions.meta | 2 +- Assets/Prefabs/Main Camera.prefab | 76 +++-- Assets/Prefabs/Player.prefab | 97 +++--- Assets/Scove/Player Movement.unity | 151 +-------- .../CameraCharacterFading.cs | 31 ++ .../CameraCharacterFading.cs.meta | 2 + .../CameraCollisionHandler.cs | 24 ++ .../CameraCollisionHandler.cs.meta | 2 + .../Camera Controller/CameraController.cs | 292 +++--------------- .../Camera Controller/CameraDynamicFOV.cs | 28 ++ .../CameraDynamicFOV.cs.meta | 2 + .../CameraOcclusionTransparency.cs | 58 ++++ .../CameraOcclusionTransparency.cs.meta | 2 + .../CameraRotationHandler.cs | 66 ++++ .../CameraRotationHandler.cs.meta | 2 + .../Camera Controller/CameraShakeManager.cs | 78 +++++ .../CameraShakeManager.cs.meta | 2 + .../Camera Controller/CameraSideBias.cs | 32 ++ .../Camera Controller/CameraSideBias.cs.meta | 2 + .../Camera Controller/CameraZoomHandler.cs | 29 ++ .../CameraZoomHandler.cs.meta | 2 + .../Scripts/Player Controller/InputReader.cs | 10 + ProjectSettings/TagManager.asset | 34 +- 25 files changed, 565 insertions(+), 537 deletions(-) create mode 100644 Assets/Scripts/Camera Controller/CameraCharacterFading.cs create mode 100644 Assets/Scripts/Camera Controller/CameraCharacterFading.cs.meta create mode 100644 Assets/Scripts/Camera Controller/CameraCollisionHandler.cs create mode 100644 Assets/Scripts/Camera Controller/CameraCollisionHandler.cs.meta create mode 100644 Assets/Scripts/Camera Controller/CameraDynamicFOV.cs create mode 100644 Assets/Scripts/Camera Controller/CameraDynamicFOV.cs.meta create mode 100644 Assets/Scripts/Camera Controller/CameraOcclusionTransparency.cs create mode 100644 Assets/Scripts/Camera Controller/CameraOcclusionTransparency.cs.meta create mode 100644 Assets/Scripts/Camera Controller/CameraRotationHandler.cs create mode 100644 Assets/Scripts/Camera Controller/CameraRotationHandler.cs.meta create mode 100644 Assets/Scripts/Camera Controller/CameraShakeManager.cs create mode 100644 Assets/Scripts/Camera Controller/CameraShakeManager.cs.meta create mode 100644 Assets/Scripts/Camera Controller/CameraSideBias.cs create mode 100644 Assets/Scripts/Camera Controller/CameraSideBias.cs.meta create mode 100644 Assets/Scripts/Camera Controller/CameraZoomHandler.cs create mode 100644 Assets/Scripts/Camera Controller/CameraZoomHandler.cs.meta diff --git a/.idea/.idea.HALLUCINATE/.idea/workspace.xml b/.idea/.idea.HALLUCINATE/.idea/workspace.xml index 2e3f61f6..c4965257 100644 --- a/.idea/.idea.HALLUCINATE/.idea/workspace.xml +++ b/.idea/.idea.HALLUCINATE/.idea/workspace.xml @@ -5,27 +5,14 @@ - + + + + + - - - - - - - - - - - - - - - - - - - + + diff --git a/Assets/InputSystem_Actions.inputactions b/Assets/InputSystem_Actions.inputactions index 1a12cb91..29ceeb76 100644 --- a/Assets/InputSystem_Actions.inputactions +++ b/Assets/InputSystem_Actions.inputactions @@ -1,4 +1,5 @@ { + "version": 1, "name": "InputSystem_Actions", "maps": [ { @@ -27,7 +28,7 @@ "name": "Attack", "type": "Button", "id": "6c2ab1b8-8984-453a-af3d-a3c78ae1679a", - "expectedControlType": "Button", + "expectedControlType": "", "processors": "", "interactions": "", "initialStateCheck": false @@ -63,7 +64,7 @@ "name": "Previous", "type": "Button", "id": "2776c80d-3c14-4091-8c56-d04ced07a2b0", - "expectedControlType": "Button", + "expectedControlType": "", "processors": "", "interactions": "", "initialStateCheck": false @@ -72,7 +73,7 @@ "name": "Next", "type": "Button", "id": "b7230bb6-fc9b-4f52-8b25-f5e19cb2c2ba", - "expectedControlType": "Button", + "expectedControlType": "", "processors": "", "interactions": "", "initialStateCheck": false @@ -85,6 +86,15 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "Scroll", + "type": "Value", + "id": "1702ffae-5ad3-4532-9855-bf7e2a8ae749", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": true } ], "bindings": [ @@ -319,6 +329,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "c1c5f1be-b30c-4565-a190-774554559b8f", + "path": "/e", + "interactions": "", + "processors": "", + "groups": "", + "action": "Next", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "cbac6039-9c09-46a1-b5f2-4e5124ccb5ed", @@ -407,6 +428,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "f6175381-88f9-4a4c-b99f-ca84606ad42d", + "path": "/q", + "interactions": "", + "processors": "", + "groups": "", + "action": "Previous", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "1534dc16-a6aa-499d-9c3a-22b47347b52a", @@ -472,6 +504,17 @@ "action": "Crouch", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "530195d8-9983-48c9-b5cf-305ee78dd292", + "path": "/scroll", + "interactions": "", + "processors": "", + "groups": "", + "action": "Scroll", + "isComposite": false, + "isPartOfComposite": false } ] }, diff --git a/Assets/InputSystem_Actions.inputactions.meta b/Assets/InputSystem_Actions.inputactions.meta index 6b38b043..ec8aca63 100644 --- a/Assets/InputSystem_Actions.inputactions.meta +++ b/Assets/InputSystem_Actions.inputactions.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 052faaac586de48259a63d0c4782560b +guid: ac73bbdc8e64ac34c9525df400c1534f ScriptedImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Assets/Prefabs/Main Camera.prefab b/Assets/Prefabs/Main Camera.prefab index 88d1ffb7..e08bd9fc 100644 --- a/Assets/Prefabs/Main Camera.prefab +++ b/Assets/Prefabs/Main Camera.prefab @@ -152,40 +152,48 @@ MonoBehaviour: m_EditorClassIdentifier: Assembly-CSharp::OnlyScove.Scripts.CameraController inputReader: {fileID: 0} followTarget: {fileID: 0} - distance: 5 - minDistance: 2 - maxDistance: 15 - zoomSensitivity: 10 - sensitivity: 20 - collisionLayers: - serializedVersion: 2 - m_Bits: 192 - cameraRadius: 0.2 positionSmoothTime: 0.08 rotationSmoothTime: 10 - useAutoRotation: 1 - autoRotateDelay: 2.5 - autoRotateSpeed: 2 - useTransparency: 1 - transparencyLayers: - serializedVersion: 2 - m_Bits: 256 - fadeAlpha: 0.3 - useDynamicFOV: 1 - baseFOV: 60 - sprintFOV: 70 - fovSmoothTime: 5 - useCharacterFading: 1 - minVisibleDistance: 1.2 - fullyHiddenDistance: 0.6 - characterRenderers: - - {fileID: 0} - useSideBias: 1 - horizontalBiasAmount: 0.5 - biasSmoothTime: 3 - useShake: 1 - minVerticalAngle: -45 - maxVerticalAngle: 45 framingOffset: {x: 0.5, y: 1.5} - invertX: 0 - invertY: 1 + rotationHandler: + sensitivity: 10 + minVerticalAngle: -45 + maxVerticalAngle: 45 + invertX: 0 + invertY: 0 + useAutoRotation: 1 + autoRotateDelay: 2.5 + autoRotateSpeed: 2 + zoomHandler: + distance: 20 + minDistance: 1 + maxDistance: 20 + zoomSensitivity: 10 + collisionHandler: + collisionLayers: + serializedVersion: 2 + m_Bits: 192 + cameraRadius: 0.2 + occlusionTransparency: + useTransparency: 1 + transparencyLayers: + serializedVersion: 2 + m_Bits: 256 + fadeAlpha: 0.3 + dynamicFOV: + useDynamicFOV: 1 + baseFOV: 60 + sprintFOV: 70 + fovSmoothTime: 5 + characterFading: + useCharacterFading: 1 + minVisibleDistance: 1.2 + fullyHiddenDistance: 0.6 + characterRenderers: + - {fileID: 0} + sideBias: + useSideBias: 1 + horizontalBiasAmount: 0.5 + biasSmoothTime: 3 + shakeManager: + useShake: 1 diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index eef303b4..bbd13b41 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -18,7 +18,6 @@ GameObject: - component: {fileID: 3043298118541876184} - component: {fileID: 3866929919288054183} - component: {fileID: 5773292363125757170} - - component: {fileID: 6232027636359170013} m_Layer: 0 m_Name: Player m_TagString: Player @@ -80,13 +79,13 @@ CharacterController: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 3 - m_Height: 1.8 - m_Radius: 0.2 + m_Height: 1.7584704 + m_Radius: 0.19215722 m_SlopeLimit: 45 - m_StepOffset: 0.3 - m_SkinWidth: 0.08 + m_StepOffset: 0.26377058 + m_SkinWidth: 0.019215723 m_MinMoveDistance: 0.001 - m_Center: {x: 0, y: 0.9, z: 0.1} + m_Center: {x: 0, y: 0.8984509, z: 0.05} --- !u!95 &9098752589608501196 Animator: serializedVersion: 7 @@ -133,7 +132,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3} m_Name: m_EditorClassIdentifier: Unity.InputSystem::UnityEngine.InputSystem.PlayerInput - m_Actions: {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3} + m_Actions: {fileID: -944628639613478452, guid: ac73bbdc8e64ac34c9525df400c1534f, type: 3} m_NotificationBehavior: 2 m_UIInputModule: {fileID: 0} m_DeviceLostEvent: @@ -180,13 +179,13 @@ MonoBehaviour: m_ActionName: 'Player/Look[/Mouse/delta]' - m_PersistentCalls: m_Calls: - - m_Target: {fileID: 1054594849095937263} - m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine - m_MethodName: - m_Mode: 1 + - m_Target: {fileID: 5600577104145922999} + m_TargetAssemblyTypeName: OnlyScove.Scripts.InputReader, Assembly-CSharp + m_MethodName: OnAttack + m_Mode: 0 m_Arguments: m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -196,13 +195,13 @@ MonoBehaviour: m_ActionName: 'Player/Attack[/Mouse/leftButton,/Keyboard/enter]' - m_PersistentCalls: m_Calls: - - m_Target: {fileID: 1054594849095937263} - m_TargetAssemblyTypeName: - m_MethodName: - m_Mode: 1 + - m_Target: {fileID: 5600577104145922999} + m_TargetAssemblyTypeName: OnlyScove.Scripts.InputReader, Assembly-CSharp + m_MethodName: OnInteract + m_Mode: 0 m_Arguments: m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -244,13 +243,13 @@ MonoBehaviour: m_ActionName: 'Player/Jump[/Keyboard/space]' - m_PersistentCalls: m_Calls: - - m_Target: {fileID: 1054594849095937263} - m_TargetAssemblyTypeName: - m_MethodName: - m_Mode: 1 + - m_Target: {fileID: 5600577104145922999} + m_TargetAssemblyTypeName: OnlyScove.Scripts.InputReader, Assembly-CSharp + m_MethodName: OnPrevious + m_Mode: 0 m_Arguments: m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -260,13 +259,13 @@ MonoBehaviour: m_ActionName: 'Player/Previous[/Keyboard/1]' - m_PersistentCalls: m_Calls: - - m_Target: {fileID: 1054594849095937263} - m_TargetAssemblyTypeName: - m_MethodName: - m_Mode: 1 + - m_Target: {fileID: 5600577104145922999} + m_TargetAssemblyTypeName: OnlyScove.Scripts.InputReader, Assembly-CSharp + m_MethodName: OnNext + m_Mode: 0 m_Arguments: m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine m_IntArgument: 0 m_FloatArgument: 0 m_StringArgument: @@ -393,7 +392,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1054594849095937263} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: e16a6690e589f0449ad89a6bf508ab62, type: 3} m_Name: @@ -410,7 +409,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1054594849095937263} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 1630760c9d97a5f4eb1bc179549c95cd, type: 3} m_Name: @@ -431,48 +430,22 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1054594849095937263} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 271dd39a46bad974485107bb1a070e0a, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::OnlyScove.Scripts.SukunaDomainController - playerStateMachine: {fileID: 0} + playerStateMachine: {fileID: 830356296960548640} slashPrefab: {fileID: 7424378359907903745, guid: 80f98b444eac25541afe9e9081c8303a, type: 3} shrinePrefab: {fileID: 5712645696331672719, guid: b0b71c635e9971346ae9ab6b7ecdd65d, type: 3} - domainVolumeProfile: {fileID: 0} + domainVolumeProfile: {fileID: 11400000, guid: 837c34edbcc0ece44ae8c54e25ec20de, type: 2} cinematicCameraPoint: {fileID: 0} - domainRadius: 15 + domainRadius: 30 domainDuration: 10 - slashRate: 15 - shrineRiseHeight: 4 + slashRate: 100 + shrineRiseHeight: 5 shrineFloorOffset: 0.5 camMoveSpeed: 4 ---- !u!114 &6232027636359170013 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1054594849095937263} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8958fecc82ae04c7d9128101addbdc3b, type: 3} - m_Name: - m_EditorClassIdentifier: WaveHarmonic.Crest::WaveHarmonic.Crest.SphereWaterInteraction - _Version: 0 - _Radius: 0.8 - _Weight: 1 - _WeightVerticalMultiplier: 0.5 - _InnerSphereMultiplier: 1.55 - _InnerSphereOffset: 0.109 - _VelocityOffset: 0.04 - _CompensateForWaveMotion: 0.45 - _BoostLargeWaves: 0 - _TeleportSpeed: 500 - _WarnOnTeleport: 0 - _MaximumSpeed: 100 - _WarnOnSpeedClamp: 0 - _DebugSubsteps: 1 --- !u!1 &4262004705141875331 GameObject: m_ObjectHideFlags: 0 @@ -772,7 +745,7 @@ PrefabInstance: - target: {fileID: 2775862123970177323, guid: 5847774ba45dc754598435b50d4a0247, type: 3} propertyPath: 'm_Materials.Array.data[0]' value: - objectReference: {fileID: 2100000, guid: 0060976ac2b2a48498435dd6d13f0b27, type: 2} + objectReference: {fileID: 3297912226980038121, guid: 8290c8e8479e3b744b22042adbe32801, type: 3} - target: {fileID: 2775862123970177323, guid: 5847774ba45dc754598435b50d4a0247, type: 3} propertyPath: 'm_Materials.Array.data[1]' value: diff --git a/Assets/Scove/Player Movement.unity b/Assets/Scove/Player Movement.unity index 936673e2..bb6b2f40 100644 --- a/Assets/Scove/Player Movement.unity +++ b/Assets/Scove/Player Movement.unity @@ -806,17 +806,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1965226596 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 830356296960548640, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - m_PrefabInstance: {fileID: 8240317044381527393} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 848ad6fdeb60b254497391392419b063, type: 3} - m_Name: - m_EditorClassIdentifier: Assembly-CSharp::OnlyScove.Scripts.PlayerStateMachine --- !u!1 &2101138892 GameObject: m_ObjectHideFlags: 0 @@ -961,6 +950,10 @@ PrefabInstance: propertyPath: m_Name value: Main Camera objectReference: {fileID: 0} + - target: {fileID: 2771692228748849855, guid: fb7874830b9e56341bf88f2a1123c677, type: 3} + propertyPath: m_Layer + value: 8 + objectReference: {fileID: 0} - target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3} propertyPath: inputReader value: @@ -977,6 +970,10 @@ PrefabInstance: propertyPath: 'characterRenderers.Array.data[0]' value: objectReference: {fileID: 166789747} + - target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3} + propertyPath: 'characterFading.characterRenderers.Array.data[0]' + value: + objectReference: {fileID: 166789747} - target: {fileID: 8391577239842762580, guid: fb7874830b9e56341bf88f2a1123c677, type: 3} propertyPath: m_RenderPostProcessing value: 1 @@ -994,6 +991,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 830356296960548640, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: k__BackingField.m_Bits + value: 512 + objectReference: {fileID: 0} - target: {fileID: 1054594849095937263, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} propertyPath: m_Name value: Player @@ -1014,86 +1015,6 @@ PrefabInstance: propertyPath: m_Camera value: objectReference: {fileID: 442028704} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Mode - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Mode - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_Mode - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_Mode - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Target - value: - objectReference: {fileID: 216247156} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Target - value: - objectReference: {fileID: 216247156} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_Target - value: - objectReference: {fileID: 216247156} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_Target - value: - objectReference: {fileID: 216247156} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName - value: OnAttack - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName - value: OnInteract - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName - value: OnPrevious - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName - value: OnNext - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName - value: OnlyScove.Scripts.InputReader, Assembly-CSharp - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName - value: OnlyScove.Scripts.InputReader, Assembly-CSharp - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName - value: OnlyScove.Scripts.InputReader, Assembly-CSharp - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName - value: OnlyScove.Scripts.InputReader, Assembly-CSharp - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName - value: UnityEngine.Object, UnityEngine - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName - value: UnityEngine.Object, UnityEngine - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName - value: UnityEngine.Object, UnityEngine - objectReference: {fileID: 0} - - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName - value: UnityEngine.Object, UnityEngine - objectReference: {fileID: 0} - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} propertyPath: m_LocalPosition.x value: -5 @@ -1146,58 +1067,10 @@ PrefabInstance: propertyPath: autoDetectOnStart value: 0 objectReference: {fileID: 0} - - target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: slashRate - value: 100 - objectReference: {fileID: 0} - - target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: domainRadius - value: 30 - objectReference: {fileID: 0} - - target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: shrineRiseHeight - value: 5 - objectReference: {fileID: 0} - - target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: playerStateMachine - value: - objectReference: {fileID: 1965226596} - - target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: domainVolumeProfile - value: - objectReference: {fileID: 11400000, guid: 837c34edbcc0ece44ae8c54e25ec20de, type: 2} - target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} propertyPath: cinematicCameraPoint value: objectReference: {fileID: 2101138893} - - target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_Height - value: 1.7584704 - objectReference: {fileID: 0} - - target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_Radius - value: 0.19215722 - objectReference: {fileID: 0} - - target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_Center.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_Center.y - value: 0.8984509 - objectReference: {fileID: 0} - - target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_Center.z - value: 0.05 - objectReference: {fileID: 0} - - target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_SkinWidth - value: 0.019215723 - objectReference: {fileID: 0} - - target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - propertyPath: m_StepOffset - value: 0.26377058 - objectReference: {fileID: 0} m_RemovedComponents: - {fileID: 6587788942094262397, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} - {fileID: 5294322338071205561, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} diff --git a/Assets/Scripts/Camera Controller/CameraCharacterFading.cs b/Assets/Scripts/Camera Controller/CameraCharacterFading.cs new file mode 100644 index 00000000..4a5b7bce --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraCharacterFading.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +namespace OnlyScove.Scripts +{ + [System.Serializable] + public class CameraCharacterFading + { + [Header("Character Fading")] + [SerializeField] private bool useCharacterFading = true; + [SerializeField] private float minVisibleDistance = 1.2f; + [SerializeField] private float fullyHiddenDistance = 0.6f; + [SerializeField] private Renderer[] characterRenderers; + + public void HandleCharacterFading(float currentDistance) + { + if (!useCharacterFading || characterRenderers == null || characterRenderers.Length == 0) return; + + float alpha = Mathf.InverseLerp(fullyHiddenDistance, minVisibleDistance, currentDistance); + + foreach (var renderer in characterRenderers) + { + if (renderer != null) + { + Color color = renderer.material.color; + color.a = alpha; + renderer.material.color = color; + } + } + } + } +} diff --git a/Assets/Scripts/Camera Controller/CameraCharacterFading.cs.meta b/Assets/Scripts/Camera Controller/CameraCharacterFading.cs.meta new file mode 100644 index 00000000..9a1f30f9 --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraCharacterFading.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5d5d8d2fa005cd34a92ee259df535130 \ No newline at end of file diff --git a/Assets/Scripts/Camera Controller/CameraCollisionHandler.cs b/Assets/Scripts/Camera Controller/CameraCollisionHandler.cs new file mode 100644 index 00000000..c1f8dce2 --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraCollisionHandler.cs @@ -0,0 +1,24 @@ +using UnityEngine; + +namespace OnlyScove.Scripts +{ + [System.Serializable] + public class CameraCollisionHandler + { + [Header("Collision Settings")] + [SerializeField] private LayerMask collisionLayers; + [SerializeField] private float cameraRadius = 0.2f; + public float CheckCollision(Vector3 focusPosition, Quaternion currentRotation, float targetDistance, float minimumDistanceAllowed) + { + RaycastHit hit; + Vector3 rayStart = focusPosition; + Vector3 rayDirection = currentRotation * Vector3.back; + + if (Physics.SphereCast(rayStart, cameraRadius, rayDirection, out hit, targetDistance, collisionLayers)) + { + return Mathf.Max(minimumDistanceAllowed, hit.distance - 0.1f); + } + return targetDistance; + } + } +} diff --git a/Assets/Scripts/Camera Controller/CameraCollisionHandler.cs.meta b/Assets/Scripts/Camera Controller/CameraCollisionHandler.cs.meta new file mode 100644 index 00000000..edf68cc9 --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraCollisionHandler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 57a506759df838e42b577ebdb542500b \ No newline at end of file diff --git a/Assets/Scripts/Camera Controller/CameraController.cs b/Assets/Scripts/Camera Controller/CameraController.cs index 451f068c..bf1e2936 100644 --- a/Assets/Scripts/Camera Controller/CameraController.cs +++ b/Assets/Scripts/Camera Controller/CameraController.cs @@ -1,287 +1,83 @@ -using System; using UnityEngine; namespace OnlyScove.Scripts { public class CameraController : MonoBehaviour { - [SerializeField] InputReader inputReader; // Kéo thả Object chứa InputReader vào đây + [SerializeField] InputReader inputReader; [SerializeField] Transform followTarget; - [SerializeField] float distance = 5; - [SerializeField] float minDistance = 2f; - [SerializeField] float maxDistance = 15f; - [SerializeField] float zoomSensitivity = 1f; - [SerializeField] float sensitivity = 0.1f; // Độ nhạy (chỉnh trong Inspector) - [SerializeField] LayerMask collisionLayers; - [SerializeField] float cameraRadius = 0.2f; - [SerializeField] float positionSmoothTime = 0.12f; // Độ trễ đuổi theo nhân vật - [SerializeField] float rotationSmoothTime = 5f; // Tốc độ làm mượt vòng xoay chuột - - [Header("Auto Rotation")] - [SerializeField] bool useAutoRotation = true; - [SerializeField] float autoRotateDelay = 2.5f; // Sau bao lâu không chạm chuột thì xoay - [SerializeField] float autoRotateSpeed = 2f; // Tốc độ xoay về sau lưng - - [Header("Occlusion Transparency")] - [SerializeField] bool useTransparency = true; - [SerializeField] LayerMask transparencyLayers; - [SerializeField] float fadeAlpha = 0.3f; // Độ trong suốt (0 là biến mất, 1 là hiện rõ) - - [Header("Dynamic FOV")] - [SerializeField] bool useDynamicFOV = true; - [SerializeField] float baseFOV = 60f; - [SerializeField] float sprintFOV = 70f; - [SerializeField] float fovSmoothTime = 5f; - - [Header("Character Fading")] - [SerializeField] bool useCharacterFading = true; - [SerializeField] float minVisibleDistance = 1.2f; // Khoảng cách bắt đầu mờ - [SerializeField] float fullyHiddenDistance = 0.6f; // Khoảng cách biến mất hẳn - [SerializeField] Renderer[] characterRenderers; // Kéo các Mesh của nhân vật vào đây - - [Header("Side Bias")] - [SerializeField] bool useSideBias = true; - [SerializeField] float horizontalBiasAmount = 0.5f; // Độ lệch sang trái/phải - [SerializeField] float biasSmoothTime = 3f; // Tốc độ chuyển đổi độ lệch - - [Header("Camera Shake")] - [SerializeField] bool useShake = true; - private float shakeIntensity = 0f; - private float shakeDuration = 0f; - private float shakeTimer = 0f; - private Vector3 shakeOffset; - - [SerializeField] float minVerticalAngle = -45f; - [SerializeField] float maxVerticalAngle = 45f; + [SerializeField] float positionSmoothTime = 0.12f; + [SerializeField] float rotationSmoothTime = 5f; [SerializeField] Vector2 framingOffset; - [SerializeField] private bool invertX; - [SerializeField] private bool invertY; - - private float rotationX; - private float rotationY; - private float invertXVal; - private float invertYVal; + [Header("Components")] + [SerializeField] private CameraRotationHandler rotationHandler = new CameraRotationHandler(); + [SerializeField] private CameraZoomHandler zoomHandler = new CameraZoomHandler(); + [SerializeField] private CameraCollisionHandler collisionHandler = new CameraCollisionHandler(); + [SerializeField] private CameraOcclusionTransparency occlusionTransparency = new CameraOcclusionTransparency(); + [SerializeField] private CameraDynamicFOV dynamicFOV = new CameraDynamicFOV(); + [SerializeField] private CameraCharacterFading characterFading = new CameraCharacterFading(); + [SerializeField] private CameraSideBias sideBias = new CameraSideBias(); + [SerializeField] private CameraShakeManager shakeManager = new CameraShakeManager(); - private float lastInputTime; - private Vector3 currentVelocity; - private Quaternion currentRotation; - - private Camera cam; - private Renderer lastFadedRenderer; - private Color originalColor; - - private float currentSideBias; + private Vector3 _currentVelocity; + private Camera _cam; private void Start() { - cam = GetComponent(); + _cam = GetComponent(); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; - // Khởi tạo vòng xoay hiện tại - rotationX = transform.eulerAngles.x; - rotationY = transform.eulerAngles.y; - currentRotation = transform.rotation; - lastInputTime = Time.time; + rotationHandler.Initialize(transform); } private void Update() { + // Handle Input-related updates first if (inputReader != null) { - // Kiểm tra xem có input xoay chuột không - if (inputReader.LookInput.magnitude > 0.01f) - { - lastInputTime = Time.time; - } - - invertXVal = (invertX) ? -1 : 1; - invertYVal = (invertY) ? -1 : 1; - - rotationX -= inputReader.LookInput.y * invertYVal * sensitivity * Time.deltaTime; - rotationX = Mathf.Clamp(rotationX, minVerticalAngle, maxVerticalAngle); - - rotationY += inputReader.LookInput.x * invertXVal * sensitivity * Time.deltaTime; - - // Logic Side Bias (Lệch khung hình khi di chuyển) - if (useSideBias) - { - float targetBias = -inputReader.MoveInput.x * horizontalBiasAmount; - currentSideBias = Mathf.Lerp(currentSideBias, targetBias, biasSmoothTime * Time.deltaTime); - } - else - { - currentSideBias = 0; - } - - // Logic Tự động xoay sau lưng (Auto-Correction) - if (useAutoRotation && Time.time - lastInputTime > autoRotateDelay) - { - // Chỉ xoay khi nhân vật đang di chuyển - if (inputReader.MoveInput.magnitude > 0.1f) - { - // Lấy hướng nhân vật đang nhìn (Yaw) - float targetYaw = followTarget.eulerAngles.y; - // Dùng LerpAngle để xoay mượt mà về hướng đó - rotationY = Mathf.LerpAngle(rotationY, targetYaw, autoRotateSpeed * Time.deltaTime); - } - } - - float scrollDelta = inputReader.ScrollInput.y; - if (Mathf.Abs(scrollDelta) > 0.1f) - { - distance -= scrollDelta * zoomSensitivity * Time.deltaTime; - distance = Mathf.Clamp(distance, minDistance, maxDistance); - } + rotationHandler.HandleRotation(inputReader, followTarget, rotationSmoothTime); + zoomHandler.HandleZoom(inputReader); + sideBias.HandleSideBias(inputReader); + dynamicFOV.HandleDynamicFOV(_cam, inputReader); } + + // Update camera rotation + transform.rotation = rotationHandler.CurrentRotation; + + // Calculate focus position with framing offset and side bias + Vector3 focusPosition = followTarget.position + rotationHandler.CurrentRotation * new Vector3(framingOffset.x + sideBias.CurrentSideBias, framingOffset.y, 0); - // Xoay chuột: Làm mượt bằng Slerp - Quaternion targetRotation = Quaternion.Euler(rotationX, rotationY, 0f); - currentRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationSmoothTime * Time.deltaTime); + // Handle collision + float targetDistance = collisionHandler.CheckCollision(focusPosition, rotationHandler.CurrentRotation, zoomHandler.CurrentDistance, zoomHandler.MinDistance); - // Vị trí mục tiêu: Áp dụng offset + Side Bias - Vector3 focusPosition = followTarget.position + currentRotation * new Vector3(framingOffset.x + currentSideBias, framingOffset.y, 0); + // Handle character fading + characterFading.HandleCharacterFading(targetDistance); + + // Calculate target position + Vector3 targetPosition = focusPosition - rotationHandler.CurrentRotation * new Vector3(0, 0, targetDistance); - // Collision Logic (Dùng currentRotation đã được làm mượt) - float targetDistance = distance; - RaycastHit hit; - Vector3 rayStart = focusPosition; - Vector3 rayDirection = currentRotation * Vector3.back; - - if (Physics.SphereCast(rayStart, cameraRadius, rayDirection, out hit, distance, collisionLayers)) - { - targetDistance = Mathf.Max(minDistance, hit.distance - 0.1f); - } - - // Logic Làm mờ nhân vật (Character Fading) - if (useCharacterFading && characterRenderers != null && characterRenderers.Length > 0) - { - HandleCharacterFading(targetDistance); - } - - // Vị trí cuối cùng: Làm mượt bằng SmoothDamp để tạo độ trễ đuổi theo - Vector3 targetPosition = focusPosition - currentRotation * new Vector3(0, 0, targetDistance); + // Handle camera shake + shakeManager.HandleShake(); - // Xử lý Camera Shake - if (useShake && shakeTimer > 0) - { - HandleShake(); - } - else - { - shakeOffset = Vector3.zero; - } - - transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref currentVelocity, positionSmoothTime) + shakeOffset; - transform.rotation = currentRotation; - - // Logic Làm trong suốt vật cản (Occlusion Transparency) - if (useTransparency) - { - HandleTransparency(focusPosition); - } - - // Logic FOV linh hoạt - if (useDynamicFOV && cam != null) - { - HandleDynamicFOV(); - } - } - - private void HandleDynamicFOV() - { - float targetFOV = baseFOV; - - // Nếu đang di chuyển và nhấn giữ nút Sprint - if (inputReader.MoveInput.magnitude > 0.1f && inputReader.IsSprintHeld) - { - targetFOV = sprintFOV; - } - - // Làm mượt quá trình thay đổi FOV - cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, targetFOV, fovSmoothTime * Time.deltaTime); - } - - private void HandleShake() - { - shakeTimer -= Time.deltaTime; + // Apply final position and rotation + transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _currentVelocity, positionSmoothTime) + shakeManager.ShakeOffset; - // Cường độ rung giảm dần theo thời gian - float currentIntensity = (shakeTimer / shakeDuration) * shakeIntensity; - - // Dùng Perlin Noise để tạo rung động mượt mà - float shakeX = (Mathf.PerlinNoise(Time.time * 25f, 0f) - 0.5f) * 2f; - float shakeY = (Mathf.PerlinNoise(0f, Time.time * 25f) - 0.5f) * 2f; - float shakeZ = (Mathf.PerlinNoise(Time.time * 25f, Time.time * 25f) - 0.5f) * 2f; - - shakeOffset = new Vector3(shakeX, shakeY, shakeZ) * currentIntensity; + // Handle occlusion transparency (needs camera's final position and rotation) + occlusionTransparency.HandleTransparency(transform, focusPosition); } public void Shake(float intensity, float duration) { - shakeIntensity = intensity; - shakeDuration = duration; - shakeTimer = duration; + shakeManager.Shake(intensity, duration); } - private void HandleCharacterFading(float currentDistance) + public void TriggerFallImpactShake(float fallHeight) { - // Tính độ mờ dựa trên khoảng cách - float alpha = Mathf.InverseLerp(fullyHiddenDistance, minVisibleDistance, currentDistance); - - foreach (var renderer in characterRenderers) - { - if (renderer != null) - { - Color color = renderer.material.color; - color.a = alpha; - renderer.material.color = color; - } - } + shakeManager.TriggerFallImpactShake(fallHeight); } - private void HandleTransparency(Vector3 focusPosition) - { - Vector3 direction = focusPosition - transform.position; - float distanceToPlayer = direction.magnitude; - RaycastHit hit; - - // Bắn một tia từ Camera đến Nhân vật - if (Physics.Raycast(transform.position, direction.normalized, out hit, distanceToPlayer, transparencyLayers)) - { - Renderer renderer = hit.collider.GetComponent(); - if (renderer != null && renderer != lastFadedRenderer) - { - // Nếu chạm vật mới, khôi phục vật cũ - ResetLastRenderer(); - - // Lưu thông tin vật mới và làm mờ - lastFadedRenderer = renderer; - originalColor = renderer.material.color; - Color fadedColor = originalColor; - fadedColor.a = fadeAlpha; - - // Lưu ý: Material cần hỗ trợ Transparency (Surface Type: Transparent trong URP) - renderer.material.color = fadedColor; - } - } - else - { - // Nếu không chạm gì, khôi phục vật cũ - ResetLastRenderer(); - } - } - - private void ResetLastRenderer() - { - if (lastFadedRenderer != null) - { - lastFadedRenderer.material.color = originalColor; - lastFadedRenderer = null; - } - } - - public Quaternion PlanarRotation => Quaternion.Euler(0f, rotationY, 0f); + public Quaternion PlanarRotation => rotationHandler.PlanarRotation; } } \ No newline at end of file diff --git a/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs b/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs new file mode 100644 index 00000000..35a9a6bd --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs @@ -0,0 +1,28 @@ +using UnityEngine; + +namespace OnlyScove.Scripts +{ + [System.Serializable] + public class CameraDynamicFOV + { + [Header("Dynamic FOV")] + [SerializeField] private bool useDynamicFOV = true; + [SerializeField] private float baseFOV = 60f; + [SerializeField] private float sprintFOV = 70f; + [SerializeField] private float fovSmoothTime = 5f; + + public void HandleDynamicFOV(Camera cam, InputReader inputReader) + { + if (!useDynamicFOV || cam == null || inputReader == null) return; + + float targetFOV = baseFOV; + + if (inputReader.MoveInput.magnitude > 0.1f && inputReader.IsSprintHeld) + { + targetFOV = sprintFOV; + } + + cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, targetFOV, fovSmoothTime * Time.deltaTime); + } + } +} diff --git a/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs.meta b/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs.meta new file mode 100644 index 00000000..499dee1a --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 99cfe3471dc945a4fad66b3b440c2c12 \ No newline at end of file diff --git a/Assets/Scripts/Camera Controller/CameraOcclusionTransparency.cs b/Assets/Scripts/Camera Controller/CameraOcclusionTransparency.cs new file mode 100644 index 00000000..c13e4e7d --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraOcclusionTransparency.cs @@ -0,0 +1,58 @@ +using UnityEngine; + +namespace OnlyScove.Scripts +{ + [System.Serializable] + public class CameraOcclusionTransparency + { + [Header("Occlusion Transparency")] + [SerializeField] private bool useTransparency = true; + [SerializeField] private LayerMask transparencyLayers; + [SerializeField] private float fadeAlpha = 0.3f; + + private Renderer _lastFadedRenderer; + private Color _originalColor; + + public void HandleTransparency(Transform cameraTransform, Vector3 focusPosition) + { + if (!useTransparency) + { + ResetLastRenderer(); + return; + } + + Vector3 direction = focusPosition - cameraTransform.position; + float distanceToPlayer = direction.magnitude; + RaycastHit hit; + + if (Physics.Raycast(cameraTransform.position, direction.normalized, out hit, distanceToPlayer, transparencyLayers)) + { + Renderer renderer = hit.collider.GetComponent(); + if (renderer != null && renderer != _lastFadedRenderer) + { + ResetLastRenderer(); + + _lastFadedRenderer = renderer; + _originalColor = renderer.material.color; + Color fadedColor = _originalColor; + fadedColor.a = fadeAlpha; + + renderer.material.color = fadedColor; + } + } + else + { + ResetLastRenderer(); + } + } + + private void ResetLastRenderer() + { + if (_lastFadedRenderer != null) + { + _lastFadedRenderer.material.color = _originalColor; + _lastFadedRenderer = null; + } + } + } +} diff --git a/Assets/Scripts/Camera Controller/CameraOcclusionTransparency.cs.meta b/Assets/Scripts/Camera Controller/CameraOcclusionTransparency.cs.meta new file mode 100644 index 00000000..b3e36a15 --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraOcclusionTransparency.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8ad64ce0d02e30243acc55aa0ebc74a9 \ No newline at end of file diff --git a/Assets/Scripts/Camera Controller/CameraRotationHandler.cs b/Assets/Scripts/Camera Controller/CameraRotationHandler.cs new file mode 100644 index 00000000..b063803e --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraRotationHandler.cs @@ -0,0 +1,66 @@ +using UnityEngine; + +namespace OnlyScove.Scripts +{ + [System.Serializable] + public class CameraRotationHandler + { + [Header("Rotation Settings")] + [SerializeField] private float sensitivity = 0.1f; + [SerializeField] private float minVerticalAngle = -45f; + [SerializeField] private float maxVerticalAngle = 45f; + [SerializeField] private bool invertX; + [SerializeField] private bool invertY; + + [Header("Auto Rotation")] + [SerializeField] private bool useAutoRotation = true; + [SerializeField] private float autoRotateDelay = 2.5f; + [SerializeField] private float autoRotateSpeed = 2f; + + private float _rotationX; + private float _rotationY; + private float _lastInputTime; + + public Quaternion CurrentRotation { get; private set; } + public Quaternion PlanarRotation => Quaternion.Euler(0f, _rotationY, 0f); + + public void Initialize(Transform cameraTransform) + { + _rotationX = cameraTransform.eulerAngles.x; + _rotationY = cameraTransform.eulerAngles.y; + _lastInputTime = Time.time; + CurrentRotation = cameraTransform.rotation; + } + + public void HandleRotation(InputReader inputReader, Transform followTarget, float rotationSmoothTime) + { + if (inputReader == null) return; + + if (inputReader.LookInput.magnitude > 0.01f) + { + _lastInputTime = Time.time; + } + + float invertXVal = (invertX) ? -1 : 1; + float invertYVal = (invertY) ? -1 : 1; + + _rotationX -= inputReader.LookInput.y * invertYVal * sensitivity * Time.deltaTime; + _rotationX = Mathf.Clamp(_rotationX, minVerticalAngle, maxVerticalAngle); + + _rotationY += inputReader.LookInput.x * invertXVal * sensitivity * Time.deltaTime; + + // Auto-Correction + if (useAutoRotation && Time.time - _lastInputTime > autoRotateDelay) + { + if (inputReader.MoveInput.magnitude > 0.1f) + { + float targetYaw = followTarget.eulerAngles.y; + _rotationY = Mathf.LerpAngle(_rotationY, targetYaw, autoRotateSpeed * Time.deltaTime); + } + } + + Quaternion targetRotation = Quaternion.Euler(_rotationX, _rotationY, 0f); + CurrentRotation = Quaternion.Slerp(CurrentRotation, targetRotation, rotationSmoothTime * Time.deltaTime); + } + } +} diff --git a/Assets/Scripts/Camera Controller/CameraRotationHandler.cs.meta b/Assets/Scripts/Camera Controller/CameraRotationHandler.cs.meta new file mode 100644 index 00000000..9b7455ce --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraRotationHandler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 92ec094a714577d49be74c0fedb3eeb3 \ No newline at end of file diff --git a/Assets/Scripts/Camera Controller/CameraShakeManager.cs b/Assets/Scripts/Camera Controller/CameraShakeManager.cs new file mode 100644 index 00000000..d54a5584 --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraShakeManager.cs @@ -0,0 +1,78 @@ +using UnityEngine; + +namespace OnlyScove.Scripts +{ + [System.Serializable] + public class CameraShakeManager + { + [SerializeField] private bool useShake = true; + [SerializeField] private float shakeFrequency = 25f; // How fast the shake oscillates + + [SerializeField] + private AnimationCurve decayCurve = AnimationCurve.EaseInOut(0, 1, 1, 0); // How intensity decays over duration + + [Header("Fall Impact Settings")] [SerializeField] + private bool enableFallImpactShake = true; + + [SerializeField] private float minFallHeightForShake = 2f; + [SerializeField] private float maxFallHeightForShake = 10f; + [SerializeField] private float minFallShakeIntensity = 0.5f; + [SerializeField] private float maxFallShakeIntensity = 3f; + [SerializeField] private float minFallShakeDuration = 0.2f; + [SerializeField] private float maxFallShakeDuration = 0.8f; + [SerializeField] private AnimationCurve fallHeightToIntensityCurve = AnimationCurve.Linear(0, 0, 1, 1); + [SerializeField] private AnimationCurve fallHeightToDurationCurve = AnimationCurve.Linear(0, 0, 1, 1); + + private float _shakeIntensity = 0f; + private float _shakeDuration = 0f; + private float _shakeTimer = 0f; // Counts down from _shakeDuration + private Vector3 _shakeOffset; + + public Vector3 ShakeOffset => _shakeOffset; + + public void HandleShake() + { + if (!useShake || _shakeTimer <= 0) + { + _shakeOffset = Vector3.zero; + return; + } + + _shakeTimer -= Time.deltaTime; + float progress = 1f - (_shakeTimer / _shakeDuration); // 0 at start, 1 at end + + // Apply decay curve to intensity + float currentIntensity = _shakeIntensity * decayCurve.Evaluate(progress); + + // Use shakeFrequency for Perlin noise + float shakeX = (Mathf.PerlinNoise(Time.time * shakeFrequency, 0f) - 0.5f) * 2f; + float shakeY = (Mathf.PerlinNoise(0f, Time.time * shakeFrequency) - 0.5f) * 2f; + float shakeZ = (Mathf.PerlinNoise(Time.time * shakeFrequency, Time.time * shakeFrequency) - 0.5f) * 2f; + + _shakeOffset = new Vector3(shakeX, shakeY, shakeZ) * currentIntensity; + } + + public void Shake(float intensity, float duration) + { + _shakeIntensity = intensity; + _shakeDuration = duration; + _shakeTimer = duration; // Reset timer + } + + public void TriggerFallImpactShake(float fallHeight) + { + if (!enableFallImpactShake || fallHeight < minFallHeightForShake) return; + + // Normalize fall height between 0 and 1 relative to min/max thresholds + float normalizedFallHeight = Mathf.InverseLerp(minFallHeightForShake, maxFallHeightForShake, fallHeight); + + // Calculate intensity and duration using curves and ranges + float intensity = Mathf.Lerp(minFallShakeIntensity, maxFallShakeIntensity, + fallHeightToIntensityCurve.Evaluate(normalizedFallHeight)); + float duration = Mathf.Lerp(minFallShakeDuration, maxFallShakeDuration, + fallHeightToDurationCurve.Evaluate(normalizedFallHeight)); + + Shake(intensity, duration); + } + } +} diff --git a/Assets/Scripts/Camera Controller/CameraShakeManager.cs.meta b/Assets/Scripts/Camera Controller/CameraShakeManager.cs.meta new file mode 100644 index 00000000..c5cd5bbb --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraShakeManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 16e87ee63ce87ac4cb7b952772318c0e \ No newline at end of file diff --git a/Assets/Scripts/Camera Controller/CameraSideBias.cs b/Assets/Scripts/Camera Controller/CameraSideBias.cs new file mode 100644 index 00000000..5234e13c --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraSideBias.cs @@ -0,0 +1,32 @@ +using UnityEngine; + +namespace OnlyScove.Scripts +{ + [System.Serializable] + public class CameraSideBias + { + [Header("Side Bias")] + [SerializeField] private bool useSideBias = true; + [SerializeField] private float horizontalBiasAmount = 0.5f; + [SerializeField] private float biasSmoothTime = 3f; + + private float _currentSideBias; + + public float CurrentSideBias => _currentSideBias; + + public void HandleSideBias(InputReader inputReader) + { + if (inputReader == null) return; + + if (useSideBias) + { + float targetBias = -inputReader.MoveInput.x * horizontalBiasAmount; + _currentSideBias = Mathf.Lerp(_currentSideBias, targetBias, biasSmoothTime * Time.deltaTime); + } + else + { + _currentSideBias = 0; + } + } + } +} diff --git a/Assets/Scripts/Camera Controller/CameraSideBias.cs.meta b/Assets/Scripts/Camera Controller/CameraSideBias.cs.meta new file mode 100644 index 00000000..2a219697 --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraSideBias.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f6bf6a3797a87fb4fb086c1625b1e7bb \ No newline at end of file diff --git a/Assets/Scripts/Camera Controller/CameraZoomHandler.cs b/Assets/Scripts/Camera Controller/CameraZoomHandler.cs new file mode 100644 index 00000000..6e2edab7 --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraZoomHandler.cs @@ -0,0 +1,29 @@ +using UnityEngine; + +namespace OnlyScove.Scripts +{ + [System.Serializable] + public class CameraZoomHandler + { + [Header("Zoom Settings")] + [SerializeField] private float distance = 5; + [SerializeField] private float minDistance = 2f; + [SerializeField] private float maxDistance = 15f; + [SerializeField] private float zoomSensitivity = 1f; + + public float CurrentDistance => distance; + public float MinDistance => minDistance; + + public void HandleZoom(InputReader inputReader) + { + if (inputReader == null) return; + + float scrollDelta = inputReader.ScrollInput.y; + if (Mathf.Abs(scrollDelta) > 0.1f) + { + distance -= scrollDelta * zoomSensitivity * Time.deltaTime; + distance = Mathf.Clamp(distance, minDistance, maxDistance); + } + } + } +} diff --git a/Assets/Scripts/Camera Controller/CameraZoomHandler.cs.meta b/Assets/Scripts/Camera Controller/CameraZoomHandler.cs.meta new file mode 100644 index 00000000..3a8edac5 --- /dev/null +++ b/Assets/Scripts/Camera Controller/CameraZoomHandler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 416c8d0f8adfcbc4390cd2e4e369e0db \ No newline at end of file diff --git a/Assets/Scripts/Player Controller/InputReader.cs b/Assets/Scripts/Player Controller/InputReader.cs index f62a3b3d..96884497 100644 --- a/Assets/Scripts/Player Controller/InputReader.cs +++ b/Assets/Scripts/Player Controller/InputReader.cs @@ -21,6 +21,7 @@ namespace OnlyScove.Scripts public event Action OnInteractEvent; // E Key public event Action OnNextInteractEvent; // R Key public event Action OnPreviousInteractEvent; // Q Key + public event Action OnToggleViewEvent; // F2 - New event for toggling camera view public void OnAttack(InputAction.CallbackContext context) { @@ -56,6 +57,15 @@ namespace OnlyScove.Scripts if (context.canceled) IsSprintHeld = false; } + // New method for ToggleView input + public void OnToggleView(InputAction.CallbackContext context) + { + if (context.performed) + { + OnToggleViewEvent?.Invoke(); + } + } + public void OnJump(InputAction.CallbackContext context) { if (context.performed) OnJumpEvent?.Invoke(); diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 6413d11f..a6998d0f 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -2,7 +2,7 @@ %TAG !u! tag:unity3d.com,2011: --- !u!78 &1 TagManager: - serializedVersion: 2 + serializedVersion: 3 tags: [] layers: - Default @@ -11,10 +11,10 @@ TagManager: - - Water - UI - - - - - - - - + - Ground + - Obstacle + - Occlusion Transparency + - Interactable - - - @@ -50,27 +50,3 @@ TagManager: - Light Layer 5 - Light Layer 6 - Light Layer 7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -