Compare commits

..

No commits in common. "21c2f14ca835851d508919a06a8ad060dabce49f" and "51c2545e357120fae796d0e7155c7eedbad6deef" have entirely different histories.

2 changed files with 29 additions and 21 deletions

View File

@ -1,28 +1,41 @@
using UnityEngine;
using System.Collections;
public class CameraShake : MonoBehaviour
{
private float shakeDuration = 0.2f;
private float shakeMagnitude = 0.3f;
[SerializeField] private float shakeDuration = 0.2f;
[SerializeField] private float shakeMagnitude = 0.1f;
private float shakeTimer = 0f;
private Vector3 targetPosition;
private Vector3 initialLocalPosition;
private Coroutine shakeCoroutine;
private void LateUpdate()
private void Awake()
{
// CameraController가 LateUpdate에서 위치를 갱신한 후 기준 위치를 저장
targetPosition = transform.position;
if (shakeTimer > 0)
{
Vector3 randomOffset = Random.insideUnitSphere * shakeMagnitude;
transform.position = targetPosition + randomOffset;
shakeTimer -= Time.deltaTime;
}
initialLocalPosition = transform.localPosition;
}
public void Shake()
{
shakeTimer = shakeDuration;
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;
}
}

View File

@ -218,18 +218,13 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
}
public void StartAttackAction()
{
if (!_isBattle) return;
public void StartAttackAction() {
_currentAction = _attackAction;
_currentAction.StartAction(this);
}
public void StartDashAction()
{
if (!_isBattle) return;
// 만약 공격 중이면 강제로 공격 종료
if (_currentAction == _attackAction && _attackAction.IsActive)
{