From 8e603ad9a4fff202f7dabf32d766b4ff17d0d5f3 Mon Sep 17 00:00:00 2001 From: Jay <96156114+jaydev00a@users.noreply.github.com> Date: Fri, 9 May 2025 18:28:25 +0900 Subject: [PATCH] =?UTF-8?q?DEG-138=20[FIX]=20=EB=8C=80=EC=8B=9C=20?= =?UTF-8?q?=EC=9D=BC=EC=83=81=EC=97=90=EC=84=9C=20=EB=A7=89=EA=B8=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EC=B9=B4=EB=A9=94=EB=9D=BC=20shake=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/JAY/Scripts/Effect/CameraShake.cs | 43 +++++++++--------------- Assets/JAY/Scripts/PlayerController.cs | 7 +++- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/Assets/JAY/Scripts/Effect/CameraShake.cs b/Assets/JAY/Scripts/Effect/CameraShake.cs index 81dd998c..cb3615b8 100644 --- a/Assets/JAY/Scripts/Effect/CameraShake.cs +++ b/Assets/JAY/Scripts/Effect/CameraShake.cs @@ -1,41 +1,28 @@ using UnityEngine; -using System.Collections; public class CameraShake : MonoBehaviour { - [SerializeField] private float shakeDuration = 0.2f; - [SerializeField] private float shakeMagnitude = 0.1f; + private float shakeDuration = 0.2f; + private float shakeMagnitude = 0.3f; - private Vector3 initialLocalPosition; - private Coroutine shakeCoroutine; + private float shakeTimer = 0f; + private Vector3 targetPosition; - private void Awake() + private void LateUpdate() { - initialLocalPosition = transform.localPosition; + // CameraController가 LateUpdate에서 위치를 갱신한 후 기준 위치를 저장 + targetPosition = transform.position; + + if (shakeTimer > 0) + { + Vector3 randomOffset = Random.insideUnitSphere * shakeMagnitude; + transform.position = targetPosition + randomOffset; + shakeTimer -= Time.deltaTime; + } } public void Shake() { - if (shakeCoroutine != null) - { - StopCoroutine(shakeCoroutine); - } - shakeCoroutine = StartCoroutine(ShakeRoutine()); - } - - private IEnumerator ShakeRoutine() - { - float elapsed = 0f; - - while (elapsed < shakeDuration) - { - Vector3 randomPoint = Random.insideUnitSphere * shakeMagnitude; - transform.localPosition = initialLocalPosition + randomPoint; - - elapsed += Time.deltaTime; - yield return null; - } - - transform.localPosition = initialLocalPosition; + shakeTimer = shakeDuration; } } \ No newline at end of file diff --git a/Assets/JAY/Scripts/PlayerController.cs b/Assets/JAY/Scripts/PlayerController.cs index 694b5fe4..1d3e3503 100644 --- a/Assets/JAY/Scripts/PlayerController.cs +++ b/Assets/JAY/Scripts/PlayerController.cs @@ -218,13 +218,18 @@ public class PlayerController : CharacterBase, IObserver } - public void StartAttackAction() { + public void StartAttackAction() + { + if (!_isBattle) return; + _currentAction = _attackAction; _currentAction.StartAction(this); } public void StartDashAction() { + if (!_isBattle) return; + // 만약 공격 중이면 강제로 공격 종료 if (_currentAction == _attackAction && _attackAction.IsActive) {