From 7b27ae51bcdca3746a6cf58428cbf7a03718e6fc Mon Sep 17 00:00:00 2001
From: Scove <104053980+Scove-Metalreal@users.noreply.github.com>
Date: Fri, 27 Mar 2026 11:21:12 +0700
Subject: [PATCH 1/4] Update
---
.idea/.idea.HALLUCINATE/.idea/indexLayout.xml | 8 +
.../.idea/projectSettingsUpdater.xml | 8 +
.idea/.idea.HALLUCINATE/.idea/vcs.xml | 6 +
.idea/.idea.HALLUCINATE/.idea/workspace.xml | 156 ++++++++++++++++++
Assets/Scove/Optimiization.unity | 4 +-
Assets/Scove/Player Movement.unity | 4 +-
Assets/Scove/Player_Movement_Description.txt | 126 --------------
.../Player_Movement_Description.txt.meta | 3 -
.../Optimization/AutoPlayerStateMachine.cs | 49 ------
.../AutoPlayerStateMachine.cs.meta | 2 -
.../Optimization/JobsMovementManager.cs | 129 ---------------
.../Optimization/JobsMovementManager.cs.meta | 2 -
Assets/Scripts/Optimization/MassiveSpawner.cs | 153 -----------------
.../Optimization/MassiveSpawner.cs.meta | 2 -
Assets/Scripts/Optimization/PerformanceHUD.cs | 34 ----
.../Optimization/PerformanceHUD.cs.meta | 2 -
.../Scripts/Optimization/StressTestSpawner.cs | 85 ----------
.../Optimization/StressTestSpawner.cs.meta | 2 -
.../Player Controller/ParkourController.cs | 59 -------
.../ParkourController.cs.meta | 2 -
.../Player Controller/PlayerController.cs | 134 ---------------
.../PlayerController.cs.meta | 2 -
Assets/Scripts/SpineProxy.cs | 65 --------
Assets/Scripts/SpineProxy.cs.meta | 2 -
.../Project Setting/FolderIcons.asset | 4 +-
ProjectSettings/SceneTemplateSettings.json | 121 ++++++++++++++
26 files changed, 305 insertions(+), 859 deletions(-)
create mode 100644 .idea/.idea.HALLUCINATE/.idea/indexLayout.xml
create mode 100644 .idea/.idea.HALLUCINATE/.idea/projectSettingsUpdater.xml
create mode 100644 .idea/.idea.HALLUCINATE/.idea/vcs.xml
create mode 100644 .idea/.idea.HALLUCINATE/.idea/workspace.xml
delete mode 100644 Assets/Scove/Player_Movement_Description.txt
delete mode 100644 Assets/Scove/Player_Movement_Description.txt.meta
delete mode 100644 Assets/Scripts/Optimization/AutoPlayerStateMachine.cs
delete mode 100644 Assets/Scripts/Optimization/AutoPlayerStateMachine.cs.meta
delete mode 100644 Assets/Scripts/Optimization/JobsMovementManager.cs
delete mode 100644 Assets/Scripts/Optimization/JobsMovementManager.cs.meta
delete mode 100644 Assets/Scripts/Optimization/MassiveSpawner.cs
delete mode 100644 Assets/Scripts/Optimization/MassiveSpawner.cs.meta
delete mode 100644 Assets/Scripts/Optimization/PerformanceHUD.cs
delete mode 100644 Assets/Scripts/Optimization/PerformanceHUD.cs.meta
delete mode 100644 Assets/Scripts/Optimization/StressTestSpawner.cs
delete mode 100644 Assets/Scripts/Optimization/StressTestSpawner.cs.meta
delete mode 100644 Assets/Scripts/Player Controller/ParkourController.cs
delete mode 100644 Assets/Scripts/Player Controller/ParkourController.cs.meta
delete mode 100644 Assets/Scripts/Player Controller/PlayerController.cs
delete mode 100644 Assets/Scripts/Player Controller/PlayerController.cs.meta
delete mode 100644 Assets/Scripts/SpineProxy.cs
delete mode 100644 Assets/Scripts/SpineProxy.cs.meta
create mode 100644 ProjectSettings/SceneTemplateSettings.json
diff --git a/.idea/.idea.HALLUCINATE/.idea/indexLayout.xml b/.idea/.idea.HALLUCINATE/.idea/indexLayout.xml
new file mode 100644
index 00000000..7b08163c
--- /dev/null
+++ b/.idea/.idea.HALLUCINATE/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.HALLUCINATE/.idea/projectSettingsUpdater.xml b/.idea/.idea.HALLUCINATE/.idea/projectSettingsUpdater.xml
new file mode 100644
index 00000000..ef20cb08
--- /dev/null
+++ b/.idea/.idea.HALLUCINATE/.idea/projectSettingsUpdater.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.HALLUCINATE/.idea/vcs.xml b/.idea/.idea.HALLUCINATE/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/.idea.HALLUCINATE/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.HALLUCINATE/.idea/workspace.xml b/.idea/.idea.HALLUCINATE/.idea/workspace.xml
new file mode 100644
index 00000000..2e3f61f6
--- /dev/null
+++ b/.idea/.idea.HALLUCINATE/.idea/workspace.xml
@@ -0,0 +1,156 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "associatedIndex": 4
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1774531360140
+
+
+ 1774531360140
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assets/Scove/Optimiization.unity b/Assets/Scove/Optimiization.unity
index 82d83ff5..17028122 100644
--- a/Assets/Scove/Optimiization.unity
+++ b/Assets/Scove/Optimiization.unity
@@ -411,7 +411,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- - {fileID: 2100000, guid: c6f1ec2975124834fbfdb5437314d9df, type: 2}
+ - {fileID: 2100000, guid: b0a84576fc378a24cbb3bfc7be45a02e, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
@@ -588,7 +588,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- - {fileID: 2100000, guid: f78dd419a717d2744a4d18615c4b199c, type: 2}
+ - {fileID: 2100000, guid: e2e2684e969402049b87d7f81417c603, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
diff --git a/Assets/Scove/Player Movement.unity b/Assets/Scove/Player Movement.unity
index 7da34e1e..936673e2 100644
--- a/Assets/Scove/Player Movement.unity
+++ b/Assets/Scove/Player Movement.unity
@@ -642,7 +642,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- - {fileID: 2100000, guid: f78dd419a717d2744a4d18615c4b199c, type: 2}
+ - {fileID: 2100000, guid: e2e2684e969402049b87d7f81417c603, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
@@ -759,7 +759,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- - {fileID: 2100000, guid: 29d8aeef71b97864a9ad6317a4738f26, type: 2}
+ - {fileID: 2100000, guid: d7e691e02b41b9a47b417cc138d6f1bc, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
diff --git a/Assets/Scove/Player_Movement_Description.txt b/Assets/Scove/Player_Movement_Description.txt
deleted file mode 100644
index 733dbca2..00000000
--- a/Assets/Scove/Player_Movement_Description.txt
+++ /dev/null
@@ -1,126 +0,0 @@
-# PROJECT CONTEXT & ARCHITECTURE
-- Engine: Unity 6.3
-- Genre: 3D Third-Person Action Game (TPS)
-- Input: Unity New Input System (using InputReader script)
-- Pattern: Hierarchical State Machine (HSM) / State Pattern
-- Coding Rules: Strictly English for all variables, methods, classes, and comments. Use CharacterController for movement. Handle rotation using Quaternion.Slerp.
-
-# 1. INPUT READER (InputReader.cs)
-Inherits: MonoBehaviour
-Properties:
-- Vector2 MoveInput (from WASD/Left Stick)
-- bool IsSprintHeld (from Left Shift - continuous hold)
-Events (Actions):
-- event Action OnJumpEvent (Space bar pressed)
-- event Action OnDodgeEvent (Right Mouse Button - RMB pressed)
-- event Action OnCrouchEvent (C key pressed)
-
-# 2. ANIMATOR SETUP REQUIREMENTS
-Parameters:
-- "Speed" (Float): Grounded movement (0.0 = Idle, 0.5 = Walk, 1.0 = Run).
-- "IsCrouching" (Bool): Toggle crouch mode.
-- "CrouchSpeed" (Float): Crouch movement (0.0 = Idle, 0.5 = Sneak, 1.0 = Walk).
-- Triggers: "Dash", "Jump", "Fall", "AirDash", "Thrust", "Dodge".
-
-# 3. STATE MACHINE CORE (PlayerStateMachine.cs)
-Inherits: MonoBehaviour
-RequireComponents: CharacterController, InputReader, Animator
-Variables:
-- float WalkSpeed = 3f, RunSpeed = 6f, DashForce = 10f, SneakSpeed = 1.5f
-- float JumpForce = 5f, Gravity = -9.81f, ThrustDownwardForce = -20f
-- float VelocityY (tracks vertical speed)
-- PlayerBaseState currentState
-Methods:
-- SwitchState(PlayerBaseState newState): calls currentState.Exit(), updates state, calls currentState.Enter().
-- Update(): calls currentState.Tick(Time.deltaTime).
-- FixedUpdate(): calls currentState.PhysicsTick(Time.fixedDeltaTime).
-
-# 4. BASE STATE (PlayerBaseState.cs)
-Abstract class. Constructor takes (PlayerStateMachine stateMachine).
-Abstract Methods: Enter(), Tick(float deltaTime), PhysicsTick(float fixedDeltaTime), Exit().
-
-# 5. DETAILED STATE LOGICS
-
-## PlayerIdleState
-- Enter: Subscribe to OnJumpEvent, OnDodgeEvent, OnCrouchEvent.
-- Tick: SmoothDamp "Speed" to 0.0. If MoveInput != Vector2.zero -> SwitchState(PlayerMoveState).
-- Exit: Unsubscribe events.
-
-## PlayerMoveState
-- Enter: Subscribe to events (Jump, Dodge, Crouch).
-- Tick:
- - If MoveInput == Vector2.zero -> SwitchState(PlayerIdleState).
- - If IsSprintHeld == true -> SwitchState(PlayerDashState).
- - Move using CharacterController (MoveInput * WalkSpeed).
- - Slerp rotation towards MoveInput direction.
- - SmoothDamp "Speed" to 0.5.
-- Exit: Unsubscribe events.
-
-## PlayerDashState
-- Variables: timer = 0.25s, dashDirection (Vector3).
-- Enter: Set dashDirection to MoveInput (or transform.forward if 0). Snap rotation to dashDirection. SetTrigger("Dash").
-- Tick:
- - Move at DashForce along dashDirection (no gravity applied).
- - timer -= deltaTime.
- - If timer <= 0:
- - If IsSprintHeld AND MoveInput != 0 -> SwitchState(PlayerRunState).
- - If MoveInput != 0 -> SwitchState(PlayerMoveState).
- - Else -> SwitchState(PlayerIdleState).
-
-## PlayerRunState
-- Enter: Subscribe to events (Jump, Dodge, Crouch).
-- Tick:
- - If MoveInput == 0 -> SwitchState(PlayerIdleState).
- - If IsSprintHeld == false -> SwitchState(PlayerMoveState).
- - Move using CharacterController (MoveInput * RunSpeed). Slerp rotation.
- - SmoothDamp "Speed" to 1.0.
-- Exit: Unsubscribe events.
-
-## PlayerJumpState
-- Enter: SetTrigger("Jump"). VelocityY = JumpForce.
-- Tick:
- - Apply Gravity (VelocityY += Gravity * deltaTime).
- - Apply horizontal Air Control (MoveInput * WalkSpeed).
- - Move using CharacterController (Horizontal + Vertical).
- - If VelocityY <= 0 -> SwitchState(PlayerFallState).
-
-## PlayerFallState
-- Enter: SetTrigger("Fall"). Subscribe to OnDodgeEvent (maps to Thrust here).
-- Tick:
- - Apply Gravity. Apply horizontal Air Control. Move via Controller.
- - If IsSprintHeld -> SwitchState(PlayerAirDashState).
- - If isGrounded -> Set VelocityY = -2f. SwitchState(Idle or Move based on input).
-- Thrust Event Trigger: SwitchState(PlayerThrustState).
-- Exit: Unsubscribe OnDodgeEvent.
-
-## PlayerAirDashState
-- Variables: timer = 0.2s, dashDir.
-- Enter: SetTrigger("AirDash"). VelocityY = 0f. Set dashDir based on MoveInput.
-- Tick:
- - Move horizontally at DashForce (VelocityY stays 0).
- - timer -= deltaTime. If timer <= 0 -> SwitchState(PlayerFallState).
-
-## PlayerThrustState
-- Enter: SetTrigger("Thrust"). VelocityY = ThrustDownwardForce.
-- Tick:
- - VelocityY += (Gravity * 2) * deltaTime. Move purely downwards (no horizontal).
- - If isGrounded -> Set VelocityY = -2f. SwitchState(PlayerIdleState).
-
-## PlayerCrouchState
-- Enter: SetBool("IsCrouching", true). Subscribe to OnCrouchEvent (Toggle), OnDodgeEvent.
-- Tick:
- - If MoveInput == 0: "CrouchSpeed" = 0.0.
- - If MoveInput != 0 AND IsSprintHeld: Move at SneakSpeed. "CrouchSpeed" = 0.5.
- - If MoveInput != 0 AND !IsSprintHeld: Move at WalkSpeed. "CrouchSpeed" = 1.0.
- - Apply Movement and Slerp rotation.
-- Toggle Event Trigger (C key): SwitchState(Idle or Move).
-- Dodge Event Trigger (LMB): SwitchState(PlayerDodgeState).
-- Exit: SetBool("IsCrouching", false). Unsubscribe events.
-
-## PlayerDodgeState
-- Variables: timer = 0.4s, dodgeDir.
-- Enter: SetTrigger("Dodge"). Set dodgeDir based on MoveInput (Left/Right/Back/Forward). Snap rotation.
-- Tick:
- - Move at (DashForce * 0.8) along dodgeDir.
- - timer -= deltaTime.
- - If timer <= 0 -> SwitchState(Idle or Move based on MoveInput).
\ No newline at end of file
diff --git a/Assets/Scove/Player_Movement_Description.txt.meta b/Assets/Scove/Player_Movement_Description.txt.meta
deleted file mode 100644
index 5fce2284..00000000
--- a/Assets/Scove/Player_Movement_Description.txt.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 0237005d5b554958bc3a87b1cec34c9e
-timeCreated: 1773378307
\ No newline at end of file
diff --git a/Assets/Scripts/Optimization/AutoPlayerStateMachine.cs b/Assets/Scripts/Optimization/AutoPlayerStateMachine.cs
deleted file mode 100644
index 6d782cc5..00000000
--- a/Assets/Scripts/Optimization/AutoPlayerStateMachine.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using UnityEngine;
-
-namespace OnlyScove.Scripts
-{
- ///
- /// A version of PlayerStateMachine that simulates constant forward or backward input.
- ///
- public class AutoPlayerStateMachine : PlayerStateMachine
- {
- [Header("Auto Pilot Settings")]
- public bool alwaysMoveForward = true;
- public bool alwaysRun = true;
- public bool isRed = false; // New property to differentiate movement direction
-
- private class FakeInputReader : InputReader
- {
- public Vector2 ForcedMove { get; set; }
- public bool ForcedSprint { get; set; }
-
- public override Vector2 MoveInput => ForcedMove;
- public override bool IsSprintHeld => ForcedSprint;
- }
-
- private FakeInputReader fakeInput;
-
- public override InputReader Input => fakeInput;
-
- protected override void Awake()
- {
- fakeInput = gameObject.AddComponent();
- base.Awake();
- }
-
- protected override void Update()
- {
- if (fakeInput != null)
- {
- // Logic updated: isRed moves backward (Vector2.down), others move forward (Vector2.up)
- fakeInput.ForcedMove = (isRed)
- ? (alwaysMoveForward ? Vector2.down : Vector2.zero)
- : (alwaysMoveForward ? Vector2.up : Vector2.zero);
-
- fakeInput.ForcedSprint = alwaysRun;
- }
-
- base.Update();
- }
- }
-}
diff --git a/Assets/Scripts/Optimization/AutoPlayerStateMachine.cs.meta b/Assets/Scripts/Optimization/AutoPlayerStateMachine.cs.meta
deleted file mode 100644
index b00381b9..00000000
--- a/Assets/Scripts/Optimization/AutoPlayerStateMachine.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: dbe8532b2e328a249bf61ae957c92486
\ No newline at end of file
diff --git a/Assets/Scripts/Optimization/JobsMovementManager.cs b/Assets/Scripts/Optimization/JobsMovementManager.cs
deleted file mode 100644
index e7f76e92..00000000
--- a/Assets/Scripts/Optimization/JobsMovementManager.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-using UnityEngine;
-using Unity.Collections;
-using Unity.Jobs;
-using UnityEngine.Jobs;
-using Unity.Burst;
-
-namespace Elbyss.Optimization
-{
- ///
- /// Manages 10,000+ objects using C# Job System and Burst Compiler.
- /// This avoids the overhead of 10,000 individual Update() calls.
- ///
- public class JobsMovementManager : MonoBehaviour
- {
- [Header("Spawn Settings")]
- public GameObject prefab;
- public int objectCount = 10000;
- public float spacing = 1.5f;
-
- [Header("Movement Settings")]
- public float speed = 5f;
-
- private TransformAccessArray transformAccessArray;
- private NativeArray directions;
- private bool isInitialized = false;
-
- private void Start()
- {
- // Optional: Start automatically or via Context Menu
- // Setup(objectCount);
- }
-
- [ContextMenu("Setup 10k Objects")]
- public void InitialSetup()
- {
- Setup(objectCount);
- }
-
- public void Setup(int count)
- {
- if (isInitialized) Cleanup();
-
- objectCount = count;
- Transform[] transforms = new Transform[objectCount];
- directions = new NativeArray(objectCount, Allocator.Persistent);
-
- int rowSize = Mathf.CeilToInt(Mathf.Sqrt(objectCount));
-
- for (int i = 0; i < objectCount; i++)
- {
- float x = (i % rowSize) * spacing;
- float z = (i / rowSize) * spacing;
- Vector3 pos = transform.position + new Vector3(x, 0, z);
-
- GameObject go = Instantiate(prefab, pos, Quaternion.identity, this.transform);
- transforms[i] = go.transform;
-
- // Set alternating directions
- directions[i] = (i % 2 == 0) ? Vector3.forward : Vector3.back;
-
- // CRITICAL OPTIMIZATION: Disable components that are too heavy for 10k objects
- if (go.TryGetComponent(out var anim)) anim.enabled = false;
- if (go.TryGetComponent(out var cc)) cc.enabled = false;
-
- // Disable all other custom scripts
- MonoBehaviour[] scripts = go.GetComponents();
- foreach (var s in scripts)
- {
- if (s != this) s.enabled = false;
- }
- }
-
- transformAccessArray = new TransformAccessArray(transforms);
- isInitialized = true;
- Debug.Log($"Initialized {objectCount} objects with Job System.");
- }
-
- private void Update()
- {
- if (!isInitialized) return;
-
- // Create the movement job
- var job = new MovementJob
- {
- DeltaTime = Time.deltaTime,
- Speed = speed,
- Directions = directions
- };
-
- // Schedule the job to run in parallel on all available CPU cores
- // transformAccessArray allows the job to modify Transform data directly
- JobHandle handle = job.Schedule(transformAccessArray);
-
- // This ensures the job is finished before the frame ends
- // In a real scenario, you might want to call Complete() in LateUpdate or next frame
- // but for simple movement, scheduling and completing in Update is fine.
- handle.Complete();
- }
-
- private void OnDestroy()
- {
- Cleanup();
- }
-
- private void Cleanup()
- {
- if (isInitialized)
- {
- if (transformAccessArray.isCreated) transformAccessArray.Dispose();
- if (directions.IsCreated) directions.Dispose();
- isInitialized = false;
- }
- }
-
- [BurstCompile] // This attribute tells the Burst compiler to optimize this job into machine code
- struct MovementJob : IJobParallelForTransform
- {
- public float DeltaTime;
- public float Speed;
- [ReadOnly] public NativeArray Directions;
-
- public void Execute(int index, TransformAccess transform)
- {
- // Directly modify the transform position in parallel
- transform.position += Directions[index] * Speed * DeltaTime;
- }
- }
- }
-}
diff --git a/Assets/Scripts/Optimization/JobsMovementManager.cs.meta b/Assets/Scripts/Optimization/JobsMovementManager.cs.meta
deleted file mode 100644
index 2c3a9a82..00000000
--- a/Assets/Scripts/Optimization/JobsMovementManager.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: 41899df442467714dbee462ae451773a
\ No newline at end of file
diff --git a/Assets/Scripts/Optimization/MassiveSpawner.cs b/Assets/Scripts/Optimization/MassiveSpawner.cs
deleted file mode 100644
index f757a4e1..00000000
--- a/Assets/Scripts/Optimization/MassiveSpawner.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-// using GPUInstancerPro;
-// using Unity.Burst;
-// using Unity.Collections;
-// using Unity.Jobs;
-// using Unity.Mathematics;
-// using UnityEngine;
-//
-// namespace Elbyss.Optimization
-// {
-// public class MassiveSpawner : MonoBehaviour
-// {
-// [Header("Spawn Settings")]
-// public GameObject prefab;
-// public GPUIProfile profile;
-// public int instanceCount = 100000;
-// public float spacing = 1.5f;
-//
-// [Header("Update Settings")]
-// public bool runUpdate = true;
-// public float movementSpeed = 1.0f;
-// public float amplitude = 2.0f;
-//
-// private int _rendererKey;
-// private NativeArray _matrices;
-// private JobHandle _jobHandle;
-// private bool _isInitialized;
-//
-// private void OnEnable()
-// {
-// Initialize();
-// }
-//
-// private void OnDisable()
-// {
-// Dispose();
-// }
-//
-// private void OnValidate()
-// {
-// if (Application.isPlaying && _isInitialized)
-// {
-// // Re-initialize if count changes during play (optional, but good for testing)
-// Initialize();
-// }
-// }
-//
-// public void Initialize()
-// {
-// Dispose();
-// if (prefab == null) return;
-//
-// if (GPUICoreAPI.RegisterRenderer(this, prefab, profile, out _rendererKey))
-// {
-// _matrices = new NativeArray(instanceCount, Allocator.Persistent);
-//
-// // Initial generation
-// GenerateMatrices(0);
-// _jobHandle.Complete();
-// GPUICoreAPI.SetTransformBufferData(_rendererKey, _matrices);
-//
-// _isInitialized = true;
-// Debug.Log($"[MassiveSpawner] Registered {instanceCount} instances with key {_rendererKey}");
-// }
-// else
-// {
-// Debug.LogError("[MassiveSpawner] Failed to register renderer!");
-// }
-// }
-//
-// private void Update()
-// {
-// if (!_isInitialized || _rendererKey == 0) return;
-//
-// if (runUpdate)
-// {
-// // Complete previous frame's work if any
-// _jobHandle.Complete();
-//
-// // Apply updated matrices to GPUI
-// GPUICoreAPI.SetTransformBufferData(_rendererKey, _matrices);
-//
-// // Schedule next frame's work
-// GenerateMatrices(Time.time);
-// }
-// }
-//
-// private void GenerateMatrices(float time)
-// {
-// int side = Mathf.CeilToInt(Mathf.Sqrt(instanceCount));
-//
-// var job = new MatrixUpdateJob
-// {
-// matrices = _matrices,
-// side = side,
-// spacing = spacing,
-// time = time,
-// speed = movementSpeed,
-// amplitude = amplitude,
-// origin = transform.position
-// };
-//
-// _jobHandle = job.Schedule(instanceCount, 64);
-// }
-//
-// public void Dispose()
-// {
-// _jobHandle.Complete();
-// if (_rendererKey != 0)
-// {
-// GPUICoreAPI.DisposeRenderer(_rendererKey);
-// _rendererKey = 0;
-// }
-//
-// if (_matrices.IsCreated)
-// {
-// _matrices.Dispose();
-// }
-// _isInitialized = false;
-// }
-//
-// [BurstCompile]
-// struct MatrixUpdateJob : IJobParallelFor
-// {
-// public NativeArray matrices;
-// public int side;
-// public float spacing;
-// public float time;
-// public float speed;
-// public float amplitude;
-// public Vector3 origin;
-//
-// public void Execute(int index)
-// {
-// int x = index % side;
-// int z = index / side;
-//
-// float xPos = x * spacing;
-// float zPos = z * spacing;
-//
-// // Add some animation to prove it's updating
-// float yPos = math.sin(time * speed + (xPos + zPos) * 0.1f) * amplitude;
-//
-// Vector3 pos = origin + new Vector3(xPos, yPos, zPos);
-//
-// // Simple rotation based on time
-// float angle = (time * speed * 10f + index) % 360f;
-// Quaternion rot = Quaternion.Euler(0, angle, 0);
-//
-// matrices[index] = Matrix4x4.TRS(pos, rot, Vector3.one);
-// }
-// }
-// }
-// }
diff --git a/Assets/Scripts/Optimization/MassiveSpawner.cs.meta b/Assets/Scripts/Optimization/MassiveSpawner.cs.meta
deleted file mode 100644
index 334b7683..00000000
--- a/Assets/Scripts/Optimization/MassiveSpawner.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: 50831f537cbccac4c9bf4067b6b158c7
\ No newline at end of file
diff --git a/Assets/Scripts/Optimization/PerformanceHUD.cs b/Assets/Scripts/Optimization/PerformanceHUD.cs
deleted file mode 100644
index a25d63f5..00000000
--- a/Assets/Scripts/Optimization/PerformanceHUD.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using UnityEngine;
-using TMPro;
-
-namespace Elbyss.Optimization
-{
- public class PerformanceHUD : MonoBehaviour
- {
- private float deltaTime = 0.0f;
- private string displayFormat = "{0:0.0} ms ({1:0.} fps)";
-
- private void Update()
- {
- deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
- }
-
- private void OnGUI()
- {
- int w = Screen.width, h = Screen.height;
-
- GUIStyle style = new GUIStyle();
-
- Rect rect = new Rect(10, 10, w, h * 2 / 100);
- style.alignment = TextAnchor.UpperLeft;
- style.fontSize = h * 2 / 50;
- style.normal.textColor = new Color(0.0f, 1.0f, 0.5f, 1.0f);
-
- float msec = deltaTime * 1000.0f;
- float fps = 1.0f / deltaTime;
- string text = string.Format(displayFormat, msec, fps);
-
- GUI.Label(rect, text, style);
- }
- }
-}
diff --git a/Assets/Scripts/Optimization/PerformanceHUD.cs.meta b/Assets/Scripts/Optimization/PerformanceHUD.cs.meta
deleted file mode 100644
index 031cdef0..00000000
--- a/Assets/Scripts/Optimization/PerformanceHUD.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: 9c9a374a3ab089d41a6784b1ffad3b6f
\ No newline at end of file
diff --git a/Assets/Scripts/Optimization/StressTestSpawner.cs b/Assets/Scripts/Optimization/StressTestSpawner.cs
deleted file mode 100644
index 72178969..00000000
--- a/Assets/Scripts/Optimization/StressTestSpawner.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using System.Collections.Generic;
-using UnityEngine;
-using OnlyScove.Scripts;
-
-namespace Elbyss.Optimization
-{
- public class StressTestSpawner : MonoBehaviour
- {
- [Header("Spawn Settings")]
- public GameObject prefabToSpawn;
- public int spawnLimit = 1000;
- public int spawnsPerFrame = 10;
- public float spacing = 2.0f;
-
- [Header("Testing Mode")]
- public bool useAutoStateMachine = true;
-
- [Header("Optimization Options")]
- public bool stripHeavyComponents = false;
-
- private List spawnedObjects = new List();
- private int currentSpawnCount = 0;
- private bool isSpawning = false;
-
- private void Update()
- {
- if (isSpawning && currentSpawnCount < spawnLimit)
- {
- for (int i = 0; i < spawnsPerFrame && currentSpawnCount < spawnLimit; i++)
- {
- SpawnObject();
- }
- }
- }
-
- [ContextMenu("Start Stress Test")]
- public void StartStressTest() => isSpawning = true;
-
- [ContextMenu("Clear All")]
- public void ClearAll()
- {
- foreach (var obj in spawnedObjects) if (obj != null) Destroy(obj);
- spawnedObjects.Clear();
- currentSpawnCount = 0;
- isSpawning = false;
- }
-
- private void SpawnObject()
- {
- if (prefabToSpawn == null) return;
-
- int rowSize = Mathf.CeilToInt(Mathf.Sqrt(spawnLimit));
- float x = (currentSpawnCount % rowSize) * spacing;
- float z = (currentSpawnCount / rowSize) * spacing;
- Vector3 spawnPos = transform.position + new Vector3(x, 0, z);
-
- GameObject newObj = Instantiate(prefabToSpawn, spawnPos, transform.rotation);
-
- if (useAutoStateMachine)
- {
- var realInput = newObj.GetComponent();
- if (realInput != null) realInput.enabled = false;
-
- var originalSM = newObj.GetComponent();
- if (originalSM != null)
- {
- DestroyImmediate(originalSM);
- var autoSM = newObj.AddComponent();
- autoSM.alwaysMoveForward = true;
- autoSM.alwaysRun = true;
- }
- }
-
- if (stripHeavyComponents)
- {
- if (newObj.TryGetComponent(out var anim)) anim.enabled = false;
- if (newObj.TryGetComponent(out var cc)) cc.enabled = false;
- if (newObj.TryGetComponent(out var sm)) sm.enabled = false;
- }
-
- spawnedObjects.Add(newObj);
- currentSpawnCount++;
- }
- }
-}
diff --git a/Assets/Scripts/Optimization/StressTestSpawner.cs.meta b/Assets/Scripts/Optimization/StressTestSpawner.cs.meta
deleted file mode 100644
index a49cd7b1..00000000
--- a/Assets/Scripts/Optimization/StressTestSpawner.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: 4a7c5ef310b7f354685dc6706be2d530
\ No newline at end of file
diff --git a/Assets/Scripts/Player Controller/ParkourController.cs b/Assets/Scripts/Player Controller/ParkourController.cs
deleted file mode 100644
index 3f515a00..00000000
--- a/Assets/Scripts/Player Controller/ParkourController.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-using System.Collections;
-using UnityEngine;
-
-namespace OnlyScove.Scripts
-{
- public class ParkourController : MonoBehaviour
- {
- [SerializeField] private InputReader inputReader;
- EnvironmentScanner environmentScanner;
- Animator animator;
- PlayerController playerController;
-
- bool inAction;
- private void Awake()
- {
- inputReader = GetComponent();
- environmentScanner = GetComponent();
- animator = GetComponent();
- playerController = GetComponent();
- }
-
- private void OnEnable()
- {
- inputReader.OnJumpEvent += HandleParkour;
- }
-
- private void OnDisable()
- {
- inputReader.OnJumpEvent -= HandleParkour;
- }
-
- private void HandleParkour()
- {
- var hitData = environmentScanner.ObstacleCheck();
-
- if (hitData.forwardHitFound)
- {
- StartCoroutine(DoParkourAction());
- }
- }
-
- IEnumerator DoParkourAction()
- {
- inAction = true;
- playerController.SetControl(false);
-
- animator.CrossFade("Step Up", 0.1f);
- yield return null;
-
- var animationState = animator.GetNextAnimatorStateInfo(0);
-
- yield return new WaitForSeconds(animationState.length);
-
- playerController.SetControl(true);
- inAction = false;
- }
- }
-}
diff --git a/Assets/Scripts/Player Controller/ParkourController.cs.meta b/Assets/Scripts/Player Controller/ParkourController.cs.meta
deleted file mode 100644
index 72f45c02..00000000
--- a/Assets/Scripts/Player Controller/ParkourController.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: 0407ea3fbe445ac43b4f1ca3077ce283
\ No newline at end of file
diff --git a/Assets/Scripts/Player Controller/PlayerController.cs b/Assets/Scripts/Player Controller/PlayerController.cs
deleted file mode 100644
index 903f8add..00000000
--- a/Assets/Scripts/Player Controller/PlayerController.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using Unity.VisualScripting;
-using UnityEngine;
-
-namespace OnlyScove.Scripts
-{
- public class PlayerController : MonoBehaviour
- {
- private static readonly int MoveAmount = Animator.StringToHash("moveAmount");
-
- [SerializeField] private InputReader inputReader;
- [SerializeField] private float rotationSpeed = 500f;
- [SerializeField] private float moveSpeed = 10f;
- [SerializeField] private float jumpHeight = 2f;
- [SerializeField] private float animationDamping = 0.2f;
- [SerializeField] private float groundCheckRadius = 0.2f;
- [SerializeField] private Vector3 groundCheckOffset;
- [SerializeField] private LayerMask groundMask;
-
- CameraController cameraController;
- Animator animator;
- private CharacterController characterController;
-
- Quaternion targetRotation;
- private float horizontal;
- private float vertical;
- bool isGrounded;
- private bool wasGrounded;
- private bool hasControl = true;
- private float ySpeed;
-
- private void Awake()
- {
- if (Camera.main != null) cameraController = Camera.main.GetComponent();
- animator = GetComponent();
- characterController = GetComponent();
- }
-
- private void OnEnable()
- {
- inputReader.OnJumpEvent += HandleJump;
- }
-
- private void OnDisable()
- {
- inputReader.OnJumpEvent -= HandleJump;
- }
-
- private void HandleJump()
- {
- if (isGrounded && hasControl)
- {
- // Công thức tính vận tốc nhảy: v = sqrt(h * -2 * g)
- ySpeed = Mathf.Sqrt(jumpHeight * -2f * Physics.gravity.y);
- }
- }
-
- private void Update()
- {
- horizontal = inputReader.MoveInput.x;
- vertical = inputReader.MoveInput.y;
- float moveAmount = Mathf.Clamp01(Math.Abs(horizontal) + Math.Abs(vertical));
-
- var moveInput = (new Vector3(horizontal, 0, vertical)).normalized;
-
- var moveDirection = cameraController.PlanarRotation * moveInput;
-
- if (!hasControl)
- return;
-
- wasGrounded = isGrounded;
- GroundCheck();
-
- // Phát hiện tiếp đất (Landing)
- if (isGrounded && !wasGrounded && ySpeed < -1f)
- {
- // Rung camera khi tiếp đất mạnh
- if (cameraController != null)
- {
- cameraController.Shake(0.2f, 0.15f);
- }
- }
-
- if (isGrounded && ySpeed < 0)
- {
- ySpeed = -2f; // Giữ nhân vật dính xuống mặt đất
- }
- else
- {
- ySpeed += Physics.gravity.y * Time.deltaTime;
- }
-
- var velocity = moveDirection * moveSpeed;
- velocity.y = ySpeed;
-
- characterController.Move(velocity * Time.deltaTime);
-
- if (moveAmount > 0)
- {
- targetRotation = Quaternion.LookRotation(moveDirection);
-
- }
-
- transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation,
- Time.deltaTime * rotationSpeed);
-
- animator.SetFloat(MoveAmount, moveAmount, animationDamping, Time.deltaTime);
- }
-
- void GroundCheck()
- {
- isGrounded =
- Physics.CheckSphere(transform.TransformPoint(groundCheckOffset), groundCheckRadius, groundMask);
- }
-
- public void SetControl(bool control)
- {
- this.hasControl = control;
- characterController.enabled = hasControl;
-
- if (!hasControl)
- {
- animator.SetFloat(MoveAmount, 0f);
- targetRotation = transform.rotation;
- }
- }
-
- private void OnDrawGizmosSelected()
- {
- Gizmos.color = new Color(0, 1, 0, 0.5f);
- Gizmos.DrawSphere(transform.TransformPoint(groundCheckOffset), groundCheckRadius);
- }
- }
-}
diff --git a/Assets/Scripts/Player Controller/PlayerController.cs.meta b/Assets/Scripts/Player Controller/PlayerController.cs.meta
deleted file mode 100644
index 791e6827..00000000
--- a/Assets/Scripts/Player Controller/PlayerController.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: cd897e8bcaabdc8408bb6aaf7c037537
\ No newline at end of file
diff --git a/Assets/Scripts/SpineProxy.cs b/Assets/Scripts/SpineProxy.cs
deleted file mode 100644
index 41c853c8..00000000
--- a/Assets/Scripts/SpineProxy.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-// -- SPINE PROXY 1.0 | Kevin Iglesias --
-// This script ensures correct animation display when mixing upper and lower body animations using Unity Avatar Masks.
-// Attach this script to the 'B-spineProxy' transform, which is a sibling of the 'B-hips' bone.
-// In the 'originalSpine' field, assign the 'B-spine' bone (child of 'B-hips' and parent of 'B-chest').
-// By default it will automatically find the 'B-spine' and assign it to the 'originalSpine' field (OnValidate).
-// When using a different character rig, manually assign the corresponding spine bone to the 'originalSpine' field and recreate
-// 'Rig > B-root > B-spine' structure in your character hierarchy with empty GameObjects.
-
-// More information: https://www.keviniglesias.com/spine-proxy.html
-// Contact Support: support@keviniglesias.com
-
-using UnityEngine;
-
-namespace KevinIglesias
-{
- public class SpineProxy : MonoBehaviour
- {
- //Assign 'B-spine' (or equivalent) here:
- [SerializeField] private Transform originalSpine;
-
- private Quaternion rotationOffset = Quaternion.identity;
-
-#if UNITY_EDITOR
- //Attempting to find the original spine bone.
- void OnValidate()
- {
- if(originalSpine == null)
- {
- Transform parent = transform.parent;
- if(parent != null)
- {
- Transform hips = parent.Find("B-hips");
- if(hips != null)
- {
- Transform spine = hips.Find("B-spine");
- if(spine != null)
- {
- originalSpine = spine;
- }
- }
- }
- }
- }
-#endif
-
- //Match correct orientation on different character rigs
- void Awake()
- {
- if(originalSpine != null)
- {//originalSpine.rotation must be the default rotation in your character T-pose when this happens:
- rotationOffset = Quaternion.Inverse(transform.rotation) * originalSpine.rotation;
- }
- }
-
- //Copy rotations from spine proxy bone to the original spine bone.
- void LateUpdate()
- {
- if(originalSpine == null)
- {
- return;
- }
- originalSpine.rotation = transform.rotation * rotationOffset;
- }
- }
-}
diff --git a/Assets/Scripts/SpineProxy.cs.meta b/Assets/Scripts/SpineProxy.cs.meta
deleted file mode 100644
index b8262516..00000000
--- a/Assets/Scripts/SpineProxy.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: 682245d9ac89ba4409aa3a92f17f5c6c
\ No newline at end of file
diff --git a/Assets/Settings/Project Setting/FolderIcons.asset b/Assets/Settings/Project Setting/FolderIcons.asset
index 2d02f5ae..13b32b09 100644
--- a/Assets/Settings/Project Setting/FolderIcons.asset
+++ b/Assets/Settings/Project Setting/FolderIcons.asset
@@ -60,10 +60,10 @@ MonoBehaviour:
- folder: {fileID: 102900000, guid: 8c41df02b38b2ee40b792b146c0493f2, type: 3}
folderIcon: {fileID: 2800000, guid: 9687b8a9002844d4b8ece997ce390043, type: 3}
overlayIcon: {fileID: 0}
- - folder: {fileID: 102900000, guid: f2f1b47c5ca0ce34d8a018d4bf5a91d8, type: 3}
+ - folder: {fileID: 102900000, guid: 4e6e9b4a0c2e35242b749c3b025c2b6d, type: 3}
folderIcon: {fileID: 2800000, guid: 45c44e19279856a4084f599ece9e9f38, type: 3}
overlayIcon: {fileID: 0}
- - folder: {fileID: 102900000, guid: 36bac883f43f8284d865986ec721bf93, type: 3}
+ - folder: {fileID: 102900000, guid: e4342b7ac2b8c524bbfd5ed650d13a32, type: 3}
folderIcon: {fileID: 2800000, guid: e73175098a6e2ea4db2ac2e6530f2b19, type: 3}
overlayIcon: {fileID: 0}
- folder: {fileID: 102900000, guid: b7be1da6c24fb324cb1b67eb7a5e6426, type: 3}
diff --git a/ProjectSettings/SceneTemplateSettings.json b/ProjectSettings/SceneTemplateSettings.json
new file mode 100644
index 00000000..ede5887b
--- /dev/null
+++ b/ProjectSettings/SceneTemplateSettings.json
@@ -0,0 +1,121 @@
+{
+ "templatePinStates": [],
+ "dependencyTypeInfos": [
+ {
+ "userAdded": false,
+ "type": "UnityEngine.AnimationClip",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEditor.Animations.AnimatorController",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.AnimatorOverrideController",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEditor.Audio.AudioMixerController",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.ComputeShader",
+ "defaultInstantiationMode": 1
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Cubemap",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.GameObject",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEditor.LightingDataAsset",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.LightingSettings",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Material",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEditor.MonoScript",
+ "defaultInstantiationMode": 1
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.PhysicsMaterial",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.PhysicsMaterial2D",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Rendering.VolumeProfile",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEditor.SceneAsset",
+ "defaultInstantiationMode": 1
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Shader",
+ "defaultInstantiationMode": 1
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.ShaderVariantCollection",
+ "defaultInstantiationMode": 1
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Texture",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Texture2D",
+ "defaultInstantiationMode": 0
+ },
+ {
+ "userAdded": false,
+ "type": "UnityEngine.Timeline.TimelineAsset",
+ "defaultInstantiationMode": 0
+ }
+ ],
+ "defaultDependencyTypeInfo": {
+ "userAdded": false,
+ "type": "",
+ "defaultInstantiationMode": 1
+ },
+ "newSceneOverride": 0
+}
\ No newline at end of file
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 2/4] 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 @@
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -118,7 +105,7 @@
1774531360140
-
+
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
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
From df1377206a0de832f17698fcd2561599c130bf68 Mon Sep 17 00:00:00 2001
From: Scove <104053980+Scove-Metalreal@users.noreply.github.com>
Date: Fri, 27 Mar 2026 12:27:50 +0700
Subject: [PATCH 3/4] Update
---
.idea/.idea.HALLUCINATE/.idea/workspace.xml | 8 +-
Assets/InputSystem_Actions.inputactions | 33 +++-
Assets/Prefabs/Player.prefab | 41 ++++-
Assets/Scove/Player Movement.unity | 49 ++++++
.../Camera Controller/CameraController.cs | 160 +++++++++++++++---
.../Camera Controller/CameraDynamicFOV.cs | 24 ++-
.../CameraRotationHandler.cs | 6 +-
7 files changed, 280 insertions(+), 41 deletions(-)
diff --git a/.idea/.idea.HALLUCINATE/.idea/workspace.xml b/.idea/.idea.HALLUCINATE/.idea/workspace.xml
index c4965257..733f2115 100644
--- a/.idea/.idea.HALLUCINATE/.idea/workspace.xml
+++ b/.idea/.idea.HALLUCINATE/.idea/workspace.xml
@@ -7,12 +7,10 @@
-
-
-
-
+
+
@@ -105,7 +103,7 @@
1774531360140
-
+
diff --git a/Assets/InputSystem_Actions.inputactions b/Assets/InputSystem_Actions.inputactions
index 29ceeb76..c66e1e10 100644
--- a/Assets/InputSystem_Actions.inputactions
+++ b/Assets/InputSystem_Actions.inputactions
@@ -82,7 +82,7 @@
"name": "Sprint",
"type": "Button",
"id": "641cd816-40e6-41b4-8c3d-04687c349290",
- "expectedControlType": "Button",
+ "expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
@@ -95,6 +95,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": true
+ },
+ {
+ "name": "ToggleView",
+ "type": "Button",
+ "id": "7e8b9416-0a2d-4652-98d8-e7368560ede9",
+ "expectedControlType": "",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": false
}
],
"bindings": [
@@ -515,6 +524,28 @@
"action": "Scroll",
"isComposite": false,
"isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "f365517f-5a04-4d18-afa0-369ab80e0c54",
+ "path": "/f2",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "ToggleView",
+ "isComposite": false,
+ "isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "048282c5-5a5b-4ab2-9777-a20889af4532",
+ "path": "/buttonEast",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "ToggleView",
+ "isComposite": false,
+ "isPartOfComposite": false
}
]
},
diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab
index bbd13b41..645c9e23 100644
--- a/Assets/Prefabs/Player.prefab
+++ b/Assets/Prefabs/Player.prefab
@@ -446,6 +446,37 @@ MonoBehaviour:
shrineRiseHeight: 5
shrineFloorOffset: 0.5
camMoveSpeed: 4
+--- !u!1 &3751838835891881608
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 5188652905305800431}
+ m_Layer: 0
+ m_Name: FPV Camera
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &5188652905305800431
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3751838835891881608}
+ serializedVersion: 2
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_ConstrainProportionsScale: 0
+ m_Children: []
+ m_Father: {fileID: 7173064969670908494}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4262004705141875331
GameObject:
m_ObjectHideFlags: 0
@@ -756,7 +787,10 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
- m_AddedGameObjects: []
+ m_AddedGameObjects:
+ - targetCorrespondingSourceObject: {fileID: -3765236089850875182, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
+ insertIndex: -1
+ addedObject: {fileID: 5188652905305800431}
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
--- !u!4 &3440275474486398839 stripped
@@ -764,3 +798,8 @@ Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
m_PrefabInstance: {fileID: 2897196837322451100}
m_PrefabAsset: {fileID: 0}
+--- !u!4 &7173064969670908494 stripped
+Transform:
+ m_CorrespondingSourceObject: {fileID: -3765236089850875182, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
+ m_PrefabInstance: {fileID: 2897196837322451100}
+ m_PrefabAsset: {fileID: 0}
diff --git a/Assets/Scove/Player Movement.unity b/Assets/Scove/Player Movement.unity
index bb6b2f40..3418ab52 100644
--- a/Assets/Scove/Player Movement.unity
+++ b/Assets/Scove/Player Movement.unity
@@ -689,6 +689,11 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!4 &1631120432 stripped
+Transform:
+ m_CorrespondingSourceObject: {fileID: 5188652905305800431, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
+ m_PrefabInstance: {fileID: 8240317044381527393}
+ m_PrefabAsset: {fileID: 0}
--- !u!4 &1732205146 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 8004958684693924044, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
@@ -954,6 +959,10 @@ PrefabInstance:
propertyPath: m_Layer
value: 8
objectReference: {fileID: 0}
+ - target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
+ propertyPath: fpvTarget
+ value:
+ objectReference: {fileID: 1631120432}
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: inputReader
value:
@@ -1015,6 +1024,46 @@ PrefabInstance:
propertyPath: m_Camera
value:
objectReference: {fileID: 442028704}
+ - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
+ propertyPath: m_ActionEvents.Array.size
+ value: 21
+ objectReference: {fileID: 0}
+ - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
+ propertyPath: m_ActionEvents.Array.data[20].m_ActionId
+ value: 7e8b9416-0a2d-4652-98d8-e7368560ede9
+ objectReference: {fileID: 0}
+ - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
+ propertyPath: m_ActionEvents.Array.data[20].m_ActionName
+ value: 'Player/Change View[/Keyboard/f2]'
+ objectReference: {fileID: 0}
+ - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
+ propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.size
+ value: 1
+ objectReference: {fileID: 0}
+ - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
+ propertyPath: m_ActionEvents.Array.data[20].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[20].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[20].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
+ value: 2
+ objectReference: {fileID: 0}
+ - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
+ propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
+ value: OnToggleView
+ objectReference: {fileID: 0}
+ - target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
+ propertyPath: m_ActionEvents.Array.data[20].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[20].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
diff --git a/Assets/Scripts/Camera Controller/CameraController.cs b/Assets/Scripts/Camera Controller/CameraController.cs
index bf1e2936..a34581ea 100644
--- a/Assets/Scripts/Camera Controller/CameraController.cs
+++ b/Assets/Scripts/Camera Controller/CameraController.cs
@@ -1,11 +1,14 @@
+using System; // For Action event
using UnityEngine;
namespace OnlyScove.Scripts
{
public class CameraController : MonoBehaviour
{
+ public enum CameraViewMode { ThirdPerson, FirstPerson }
+
[SerializeField] InputReader inputReader;
- [SerializeField] Transform followTarget;
+ [SerializeField] Transform followTarget; // Player's root for TPV
[SerializeField] float positionSmoothTime = 0.12f;
[SerializeField] float rotationSmoothTime = 5f;
[SerializeField] Vector2 framingOffset;
@@ -19,53 +22,160 @@ namespace OnlyScove.Scripts
[SerializeField] private CameraCharacterFading characterFading = new CameraCharacterFading();
[SerializeField] private CameraSideBias sideBias = new CameraSideBias();
[SerializeField] private CameraShakeManager shakeManager = new CameraShakeManager();
-
+
+ [Header("First Person View Settings")]
+ [SerializeField] Transform fpvTarget; // Specific transform on the player (e.g., eye level)
+ [SerializeField] float fpvPositionSmoothTime = 0.05f;
+ [SerializeField] float fpvRotationSmoothTime = 0.05f;
+ [SerializeField] float fpvFOV = 80f;
+ [SerializeField] float transitionDuration = 0.3f;
+ [SerializeField] float tpvBaseFOV = 60f; // Existing base FOV for TPV
+
private Vector3 _currentVelocity;
private Camera _cam;
+ private CameraViewMode _currentViewMode = CameraViewMode.ThirdPerson;
+ private CameraViewMode _targetViewMode = CameraViewMode.ThirdPerson;
+ private float _transitionTimer = 0f;
+ private bool _inTransition = false;
+
+ // Properties to get current smoothing values based on view mode
+ private float CurrentPositionSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvPositionSmoothTime : positionSmoothTime;
+ private float CurrentRotationSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvRotationSmoothTime : rotationSmoothTime;
+
+ private void OnEnable()
+ {
+ if (inputReader != null)
+ {
+ inputReader.OnToggleViewEvent += ToggleCameraView;
+ }
+ }
+
+ private void OnDisable()
+ {
+ if (inputReader != null)
+ {
+ inputReader.OnToggleViewEvent -= ToggleCameraView;
+ }
+ }
private void Start()
{
_cam = GetComponent();
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
-
+
rotationHandler.Initialize(transform);
+ dynamicFOV.Initialize(tpvBaseFOV: tpvBaseFOV, fpvFOV: fpvFOV); // Pass TPV and FPV base FOVs
}
private void Update()
{
- // Handle Input-related updates first
+ HandleViewTransition();
+
if (inputReader != null)
{
- rotationHandler.HandleRotation(inputReader, followTarget, rotationSmoothTime);
- zoomHandler.HandleZoom(inputReader);
- sideBias.HandleSideBias(inputReader);
- dynamicFOV.HandleDynamicFOV(_cam, inputReader);
+ // Input-related updates are handled differently based on view mode
+ rotationHandler.HandleRotation(inputReader, followTarget, CurrentRotationSmoothTime, _currentViewMode);
+
+ if (_currentViewMode == CameraViewMode.ThirdPerson)
+ {
+ zoomHandler.HandleZoom(inputReader);
+ sideBias.HandleSideBias(inputReader);
+ }
+ else
+ {
+ // Disable side bias and zoom in FPV
+ sideBias.HandleSideBias(null); // Pass null to effectively disable
+ zoomHandler.HandleZoom(null); // Pass null to effectively disable
+ }
+ dynamicFOV.HandleDynamicFOV(_cam, inputReader, _currentViewMode);
}
- // Update camera rotation
- transform.rotation = rotationHandler.CurrentRotation;
+ Vector3 focusPosition;
+ float targetDistance;
- // Calculate focus position with framing offset and side bias
- Vector3 focusPosition = followTarget.position + rotationHandler.CurrentRotation * new Vector3(framingOffset.x + sideBias.CurrentSideBias, framingOffset.y, 0);
-
- // Handle collision
- float targetDistance = collisionHandler.CheckCollision(focusPosition, rotationHandler.CurrentRotation, zoomHandler.CurrentDistance, zoomHandler.MinDistance);
+ if (_currentViewMode == CameraViewMode.ThirdPerson)
+ {
+ // TPV specific calculations
+ transform.rotation = rotationHandler.CurrentRotation; // Set rotation from handler
+ focusPosition = followTarget.position + rotationHandler.CurrentRotation * new Vector3(framingOffset.x + sideBias.CurrentSideBias, framingOffset.y, 0);
+ targetDistance = collisionHandler.CheckCollision(focusPosition, rotationHandler.CurrentRotation, zoomHandler.CurrentDistance, zoomHandler.MinDistance);
+ characterFading.HandleCharacterFading(targetDistance);
+ occlusionTransparency.HandleTransparency(transform, focusPosition);
+ }
+ else // FirstPerson
+ {
+ // FPV specific calculations
+ // Rotation is derived from fpvTarget, not input from rotationHandler
+ transform.rotation = fpvTarget.rotation; // Directly set FPV rotation
+ focusPosition = fpvTarget.position;
+ targetDistance = 0; // FPV has no distance to player
- // Handle character fading
- characterFading.HandleCharacterFading(targetDistance);
+ // Disable TPV-specific effects
+ characterFading.HandleCharacterFading(0); // Fully opaque character in FPV
+ occlusionTransparency.HandleTransparency(transform, fpvTarget.position); // Can still have occlusion transparency for environment in FPV
+ }
+
+ // Calculate target position using the currently set transform.rotation
+ Vector3 targetPosition = focusPosition - transform.rotation * new Vector3(0, 0, targetDistance);
- // Calculate target position
- Vector3 targetPosition = focusPosition - rotationHandler.CurrentRotation * new Vector3(0, 0, targetDistance);
-
// Handle camera shake
shakeManager.HandleShake();
-
+
// Apply final position and rotation
- transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _currentVelocity, positionSmoothTime) + shakeManager.ShakeOffset;
-
- // Handle occlusion transparency (needs camera's final position and rotation)
- occlusionTransparency.HandleTransparency(transform, focusPosition);
+ transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _currentVelocity, CurrentPositionSmoothTime) + shakeManager.ShakeOffset;
+ }
+
+ private void ToggleCameraView()
+ {
+ if (_inTransition) return; // Prevent multiple toggles during transition
+
+ _targetViewMode = (_currentViewMode == CameraViewMode.ThirdPerson) ? CameraViewMode.FirstPerson : CameraViewMode.ThirdPerson;
+ _inTransition = true;
+ _transitionTimer = 0f;
+ }
+
+ private void HandleViewTransition()
+ {
+ if (!_inTransition) return;
+
+ _transitionTimer += Time.deltaTime;
+ float t = _transitionTimer / transitionDuration;
+ t = Mathf.Clamp01(t); // Clamp t between 0 and 1
+
+ // Smoothly interpolate parameters during transition
+ if (_currentViewMode == CameraViewMode.ThirdPerson && _targetViewMode == CameraViewMode.FirstPerson)
+ {
+ // TPV -> FPV transition
+ // Interpolate FOV
+ _cam.fieldOfView = Mathf.Lerp(dynamicFOV.CurrentTpvBaseFOV, fpvFOV, t);
+ // Interpolate position and rotation
+ transform.position = Vector3.Lerp(transform.position, fpvTarget.position, t);
+ transform.rotation = Quaternion.Slerp(transform.rotation, fpvTarget.rotation, t);
+ }
+ else if (_currentViewMode == CameraViewMode.FirstPerson && _targetViewMode == CameraViewMode.ThirdPerson)
+ {
+ // FPV -> TPV transition
+ // Interpolate FOV
+ _cam.fieldOfView = Mathf.Lerp(fpvFOV, dynamicFOV.CurrentTpvBaseFOV, t);
+ // For position and rotation, we'll let the TPV logic take over after transition.
+ // If a smooth exit from FPV to TPV is desired for position/rotation,
+ // more complex calculations would be needed here to store TPV target position/rotation at the start.
+ }
+
+ if (t >= 1f)
+ {
+ _currentViewMode = _targetViewMode;
+ _inTransition = false;
+ // Re-initialize rotation handler for new view mode context
+ rotationHandler.Initialize(transform);
+
+ // Ensure FOV is set correctly at the end of transition
+ _cam.fieldOfView = (_currentViewMode == CameraViewMode.FirstPerson) ? fpvFOV : dynamicFOV.CurrentTpvBaseFOV;
+
+ // For FPV, ensure camera matches fpvTarget immediately after transition
+ // This is already handled by the `transform.position = Vector3.SmoothDamp...` and `transform.rotation = fpvTarget.rotation` in Update
+ }
}
public void Shake(float intensity, float duration)
diff --git a/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs b/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs
index 35a9a6bd..5a8f6143 100644
--- a/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs
+++ b/Assets/Scripts/Camera Controller/CameraDynamicFOV.cs
@@ -1,4 +1,5 @@
using UnityEngine;
+using static OnlyScove.Scripts.CameraController; // Need to add this to access CameraController.CameraViewMode
namespace OnlyScove.Scripts
{
@@ -7,19 +8,30 @@ namespace OnlyScove.Scripts
{
[Header("Dynamic FOV")]
[SerializeField] private bool useDynamicFOV = true;
- [SerializeField] private float baseFOV = 60f;
- [SerializeField] private float sprintFOV = 70f;
+ [SerializeField] private float tpvSprintFOV = 70f; // Renamed from sprintFOV for clarity
[SerializeField] private float fovSmoothTime = 5f;
- public void HandleDynamicFOV(Camera cam, InputReader inputReader)
+ private float _currentTpvBaseFOV; // Stored from CameraController
+ private float _currentFpvFOV; // Stored from CameraController
+
+ public float CurrentTpvBaseFOV => _currentTpvBaseFOV; // Expose for CameraController transitions
+
+ public void Initialize(float tpvBaseFOV, float fpvFOV)
+ {
+ _currentTpvBaseFOV = tpvBaseFOV;
+ _currentFpvFOV = fpvFOV;
+ }
+
+ public void HandleDynamicFOV(Camera cam, InputReader inputReader, CameraViewMode viewMode)
{
if (!useDynamicFOV || cam == null || inputReader == null) return;
- float targetFOV = baseFOV;
+ float targetFOV = (viewMode == CameraViewMode.ThirdPerson) ? _currentTpvBaseFOV : _currentFpvFOV;
- if (inputReader.MoveInput.magnitude > 0.1f && inputReader.IsSprintHeld)
+ // Apply sprint FOV only in TPV
+ if (viewMode == CameraViewMode.ThirdPerson && inputReader.MoveInput.magnitude > 0.1f && inputReader.IsSprintHeld)
{
- targetFOV = sprintFOV;
+ targetFOV = tpvSprintFOV;
}
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, targetFOV, fovSmoothTime * Time.deltaTime);
diff --git a/Assets/Scripts/Camera Controller/CameraRotationHandler.cs b/Assets/Scripts/Camera Controller/CameraRotationHandler.cs
index b063803e..473ba957 100644
--- a/Assets/Scripts/Camera Controller/CameraRotationHandler.cs
+++ b/Assets/Scripts/Camera Controller/CameraRotationHandler.cs
@@ -1,4 +1,5 @@
using UnityEngine;
+using static OnlyScove.Scripts.CameraController;
namespace OnlyScove.Scripts
{
@@ -32,9 +33,9 @@ namespace OnlyScove.Scripts
CurrentRotation = cameraTransform.rotation;
}
- public void HandleRotation(InputReader inputReader, Transform followTarget, float rotationSmoothTime)
+ public void HandleRotation(InputReader inputReader, Transform followTarget, float rotationSmoothTime, CameraViewMode viewMode)
{
- if (inputReader == null) return;
+ if (inputReader == null || viewMode == CameraViewMode.FirstPerson) return; // Only process input in TPV
if (inputReader.LookInput.magnitude > 0.01f)
{
@@ -58,7 +59,6 @@ namespace OnlyScove.Scripts
_rotationY = Mathf.LerpAngle(_rotationY, targetYaw, autoRotateSpeed * Time.deltaTime);
}
}
-
Quaternion targetRotation = Quaternion.Euler(_rotationX, _rotationY, 0f);
CurrentRotation = Quaternion.Slerp(CurrentRotation, targetRotation, rotationSmoothTime * Time.deltaTime);
}
From ed67b8258d016bb8769795a8d05ac6eacd348d17 Mon Sep 17 00:00:00 2001
From: Scove <104053980+Scove-Metalreal@users.noreply.github.com>
Date: Fri, 27 Mar 2026 20:20:06 +0700
Subject: [PATCH 4/4] Update
---
.idea/.idea.HALLUCINATE/.idea/workspace.xml | 8 ++-
.../Camera Controller/CameraController.cs | 50 +++++++++++++------
.../CameraRotationHandler.cs | 49 ++++++++++++++----
.../Player Controller/PlayerMoveState.cs | 5 ++
4 files changed, 82 insertions(+), 30 deletions(-)
diff --git a/.idea/.idea.HALLUCINATE/.idea/workspace.xml b/.idea/.idea.HALLUCINATE/.idea/workspace.xml
index 733f2115..b8c8ca80 100644
--- a/.idea/.idea.HALLUCINATE/.idea/workspace.xml
+++ b/.idea/.idea.HALLUCINATE/.idea/workspace.xml
@@ -6,11 +6,9 @@
-
-
-
+
@@ -18,7 +16,7 @@
-
+
@@ -103,7 +101,7 @@
1774531360140
-
+
diff --git a/Assets/Scripts/Camera Controller/CameraController.cs b/Assets/Scripts/Camera Controller/CameraController.cs
index a34581ea..da7690c9 100644
--- a/Assets/Scripts/Camera Controller/CameraController.cs
+++ b/Assets/Scripts/Camera Controller/CameraController.cs
@@ -26,7 +26,7 @@ namespace OnlyScove.Scripts
[Header("First Person View Settings")]
[SerializeField] Transform fpvTarget; // Specific transform on the player (e.g., eye level)
[SerializeField] float fpvPositionSmoothTime = 0.05f;
- [SerializeField] float fpvRotationSmoothTime = 0.05f;
+ [SerializeField] float fpvRotationSmoothTime = 20f;
[SerializeField] float fpvFOV = 80f;
[SerializeField] float transitionDuration = 0.3f;
[SerializeField] float tpvBaseFOV = 60f; // Existing base FOV for TPV
@@ -38,6 +38,8 @@ namespace OnlyScove.Scripts
private float _transitionTimer = 0f;
private bool _inTransition = false;
+ public CameraViewMode CurrentViewMode => _currentViewMode;
+
// Properties to get current smoothing values based on view mode
private float CurrentPositionSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvPositionSmoothTime : positionSmoothTime;
private float CurrentRotationSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvRotationSmoothTime : rotationSmoothTime;
@@ -97,7 +99,7 @@ namespace OnlyScove.Scripts
if (_currentViewMode == CameraViewMode.ThirdPerson)
{
// TPV specific calculations
- transform.rotation = rotationHandler.CurrentRotation; // Set rotation from handler
+ transform.rotation = rotationHandler.CurrentRotation; // Set camera rotation from handler
focusPosition = followTarget.position + rotationHandler.CurrentRotation * new Vector3(framingOffset.x + sideBias.CurrentSideBias, framingOffset.y, 0);
targetDistance = collisionHandler.CheckCollision(focusPosition, rotationHandler.CurrentRotation, zoomHandler.CurrentDistance, zoomHandler.MinDistance);
characterFading.HandleCharacterFading(targetDistance);
@@ -106,8 +108,18 @@ namespace OnlyScove.Scripts
else // FirstPerson
{
// FPV specific calculations
- // Rotation is derived from fpvTarget, not input from rotationHandler
- transform.rotation = fpvTarget.rotation; // Directly set FPV rotation
+ // Player's horizontal rotation (body) follows mouse YAW
+ if (followTarget != null)
+ {
+ followTarget.rotation = rotationHandler.PlanarRotation; // Sync body to camera yaw
+ }
+
+ if (fpvTarget != null)
+ {
+ fpvTarget.rotation = rotationHandler.CurrentRotation; // Sync head/eyes to full camera rotation
+ }
+
+ transform.rotation = rotationHandler.CurrentRotation; // Set camera rotation from handler (which includes vertical)
focusPosition = fpvTarget.position;
targetDistance = 0; // FPV has no distance to player
@@ -117,8 +129,7 @@ namespace OnlyScove.Scripts
}
// Calculate target position using the currently set transform.rotation
- Vector3 targetPosition = focusPosition - transform.rotation * new Vector3(0, 0, targetDistance);
-
+ Vector3 targetPosition = focusPosition - transform.rotation * new Vector3(0, 0, targetDistance);
// Handle camera shake
shakeManager.HandleShake();
@@ -131,6 +142,7 @@ namespace OnlyScove.Scripts
if (_inTransition) return; // Prevent multiple toggles during transition
_targetViewMode = (_currentViewMode == CameraViewMode.ThirdPerson) ? CameraViewMode.FirstPerson : CameraViewMode.ThirdPerson;
+ Debug.Log($"[CameraController] Toggling view from {_currentViewMode} to {_targetViewMode}");
_inTransition = true;
_transitionTimer = 0f;
}
@@ -149,6 +161,13 @@ namespace OnlyScove.Scripts
// TPV -> FPV transition
// Interpolate FOV
_cam.fieldOfView = Mathf.Lerp(dynamicFOV.CurrentTpvBaseFOV, fpvFOV, t);
+
+ // Rotate player body to match camera's intended horizontal look direction
+ if (followTarget != null)
+ {
+ followTarget.rotation = Quaternion.Slerp(followTarget.rotation, rotationHandler.PlanarRotation, t);
+ }
+
// Interpolate position and rotation
transform.position = Vector3.Lerp(transform.position, fpvTarget.position, t);
transform.rotation = Quaternion.Slerp(transform.rotation, fpvTarget.rotation, t);
@@ -158,23 +177,26 @@ namespace OnlyScove.Scripts
// FPV -> TPV transition
// Interpolate FOV
_cam.fieldOfView = Mathf.Lerp(fpvFOV, dynamicFOV.CurrentTpvBaseFOV, t);
- // For position and rotation, we'll let the TPV logic take over after transition.
- // If a smooth exit from FPV to TPV is desired for position/rotation,
- // more complex calculations would be needed here to store TPV target position/rotation at the start.
}
if (t >= 1f)
{
_currentViewMode = _targetViewMode;
+ Debug.Log($"[CameraController] View transition complete. Current mode: {_currentViewMode}");
_inTransition = false;
- // Re-initialize rotation handler for new view mode context
- rotationHandler.Initialize(transform);
+
+ // Initialize rotation handler based on new view mode
+ if (_currentViewMode == CameraViewMode.FirstPerson && fpvTarget != null)
+ {
+ rotationHandler.InitializeFPV(fpvTarget); // Initialize FPV rotation handler
+ }
+ else
+ {
+ rotationHandler.Initialize(transform); // Initialize TPV rotation handler
+ }
// Ensure FOV is set correctly at the end of transition
_cam.fieldOfView = (_currentViewMode == CameraViewMode.FirstPerson) ? fpvFOV : dynamicFOV.CurrentTpvBaseFOV;
-
- // For FPV, ensure camera matches fpvTarget immediately after transition
- // This is already handled by the `transform.position = Vector3.SmoothDamp...` and `transform.rotation = fpvTarget.rotation` in Update
}
}
diff --git a/Assets/Scripts/Camera Controller/CameraRotationHandler.cs b/Assets/Scripts/Camera Controller/CameraRotationHandler.cs
index 473ba957..55f847be 100644
--- a/Assets/Scripts/Camera Controller/CameraRotationHandler.cs
+++ b/Assets/Scripts/Camera Controller/CameraRotationHandler.cs
@@ -1,5 +1,5 @@
using UnityEngine;
-using static OnlyScove.Scripts.CameraController;
+using static OnlyScove.Scripts.CameraController;
namespace OnlyScove.Scripts
{
@@ -22,8 +22,8 @@ namespace OnlyScove.Scripts
private float _rotationY;
private float _lastInputTime;
- public Quaternion CurrentRotation { get; private set; }
- public Quaternion PlanarRotation => Quaternion.Euler(0f, _rotationY, 0f);
+ public Quaternion CurrentRotation { get; private set; } // Camera's actual rotation
+ public Quaternion PlanarRotation => Quaternion.Euler(0f, _rotationY, 0f); // Horizontal rotation (for player body in FPV)
public void Initialize(Transform cameraTransform)
{
@@ -33,10 +33,27 @@ namespace OnlyScove.Scripts
CurrentRotation = cameraTransform.rotation;
}
+ // New method to initialize rotation specifically for FPV
+ public void InitializeFPV(Transform fpvTargetTransform)
+ {
+ _rotationX = fpvTargetTransform.localEulerAngles.x; // Use local rotation for vertical angle in FPV
+ _rotationY = fpvTargetTransform.eulerAngles.y; // Use world rotation for horizontal angle
+ _lastInputTime = Time.time;
+ CurrentRotation = fpvTargetTransform.rotation; // Camera starts matching fpvTarget rotation
+ }
+
+
public void HandleRotation(InputReader inputReader, Transform followTarget, float rotationSmoothTime, CameraViewMode viewMode)
{
- if (inputReader == null || viewMode == CameraViewMode.FirstPerson) return; // Only process input in TPV
+ if (inputReader == null) return;
+ // Debug for rotation
+ if (inputReader.LookInput.sqrMagnitude > 0.001f)
+ {
+ Debug.Log($"[CameraRotationHandler] LookInput: {inputReader.LookInput}, _rotationX: {_rotationX}, _rotationY: {_rotationY}, ViewMode: {viewMode}");
+ }
+
+ // Update _lastInputTime regardless of view mode if there's look input
if (inputReader.LookInput.magnitude > 0.01f)
{
_lastInputTime = Time.time;
@@ -50,17 +67,27 @@ namespace OnlyScove.Scripts
_rotationY += inputReader.LookInput.x * invertXVal * sensitivity * Time.deltaTime;
- // Auto-Correction
- if (useAutoRotation && Time.time - _lastInputTime > autoRotateDelay)
+ if (viewMode == CameraViewMode.ThirdPerson)
{
- if (inputReader.MoveInput.magnitude > 0.1f)
+ // Auto-Correction for TPV
+ if (useAutoRotation && Time.time - _lastInputTime > autoRotateDelay)
{
- float targetYaw = followTarget.eulerAngles.y;
- _rotationY = Mathf.LerpAngle(_rotationY, targetYaw, autoRotateSpeed * Time.deltaTime);
+ 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);
+ }
+ else // FirstPerson
+ {
+ // In FPV, CurrentRotation *is* the camera's rotation (head rotation)
+ // The horizontal part of this (_rotationY) will also be used to rotate the player's body.
+ Quaternion targetRotation = Quaternion.Euler(_rotationX, _rotationY, 0f);
+ CurrentRotation = Quaternion.Slerp(CurrentRotation, targetRotation, rotationSmoothTime * Time.deltaTime);
}
- Quaternion targetRotation = Quaternion.Euler(_rotationX, _rotationY, 0f);
- CurrentRotation = Quaternion.Slerp(CurrentRotation, targetRotation, rotationSmoothTime * Time.deltaTime);
}
}
}
diff --git a/Assets/Scripts/Player Controller/PlayerMoveState.cs b/Assets/Scripts/Player Controller/PlayerMoveState.cs
index 01d8d195..4040fa2a 100644
--- a/Assets/Scripts/Player Controller/PlayerMoveState.cs
+++ b/Assets/Scripts/Player Controller/PlayerMoveState.cs
@@ -36,6 +36,11 @@ namespace OnlyScove.Scripts
Vector3 inputDir = new Vector3(input.x, 0, input.y).normalized;
Vector3 moveDirection = stateMachine.Cam != null ? stateMachine.Cam.PlanarRotation * inputDir : inputDir;
+ if (stateMachine.Cam != null)
+ {
+ Debug.Log($"[PlayerMoveState] View: {(stateMachine.Cam.PlanarRotation.eulerAngles.y)}, InputDir: {inputDir}, MoveDir: {moveDirection}, PlayerRot: {stateMachine.transform.rotation.eulerAngles.y}");
+ }
+
Vector3 velocity = moveDirection * stateMachine.RunSpeed;
if (stateMachine.IsGrounded && stateMachine.VelocityY < 0)