Merge pull request 'DEG-138 [FIX] 대시 일상에서 막기 및 카메라 shake 수정' (!26) from DEG-138-대시-일상에서-막기-카메라-shake-수정 into main
Reviewed-on: #26 Reviewed-by: FioreFlower <cjsdlf44@gmail.com> Reviewed-by: Sehyeon <sehyeon1837@gmail.com>
This commit is contained in:
commit
21c2f14ca8
@ -1,41 +1,28 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
public class CameraShake : MonoBehaviour
|
public class CameraShake : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private float shakeDuration = 0.2f;
|
private float shakeDuration = 0.2f;
|
||||||
[SerializeField] private float shakeMagnitude = 0.1f;
|
private float shakeMagnitude = 0.3f;
|
||||||
|
|
||||||
private Vector3 initialLocalPosition;
|
private float shakeTimer = 0f;
|
||||||
private Coroutine shakeCoroutine;
|
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()
|
public void Shake()
|
||||||
{
|
{
|
||||||
if (shakeCoroutine != null)
|
shakeTimer = shakeDuration;
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -218,13 +218,18 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void StartAttackAction() {
|
public void StartAttackAction()
|
||||||
|
{
|
||||||
|
if (!_isBattle) return;
|
||||||
|
|
||||||
_currentAction = _attackAction;
|
_currentAction = _attackAction;
|
||||||
_currentAction.StartAction(this);
|
_currentAction.StartAction(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartDashAction()
|
public void StartDashAction()
|
||||||
{
|
{
|
||||||
|
if (!_isBattle) return;
|
||||||
|
|
||||||
// 만약 공격 중이면 강제로 공격 종료
|
// 만약 공격 중이면 강제로 공격 종료
|
||||||
if (_currentAction == _attackAction && _attackAction.IsActive)
|
if (_currentAction == _attackAction && _attackAction.IsActive)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user