2026-05-18 공격에 의한 이동량 초기화
This commit is contained in:
@@ -73,13 +73,18 @@ public void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReac
|
||||
if (_anim != null && !string.IsNullOrEmpty(hitReactionAnimationState))
|
||||
_anim.Play(hitReactionAnimationState);
|
||||
|
||||
// HitVelocity is an immediate launch/knockback velocity, not an additive force.
|
||||
// 새 피격이 반응 속도를 전부 결정하므로, 이전 튕김/넉백 속도는 먼저 제거한다.
|
||||
if (_rb != null)
|
||||
{
|
||||
_hitReactionTimer = 0f;
|
||||
_rb.linearVelocity = Vector2.zero;
|
||||
_lastVelocity = Vector2.zero;
|
||||
|
||||
Vector2 nextVelocity = GetHitReactionVelocity(hitVelocity);
|
||||
if (nextVelocity != Vector2.zero)
|
||||
{
|
||||
_rb.linearVelocity = nextVelocity;
|
||||
_lastVelocity = nextVelocity;
|
||||
_hitReactionTimer = _hitReactionDuration;
|
||||
}
|
||||
}
|
||||
@@ -117,13 +122,11 @@ private void OnCollisionExit2D(Collision2D collision)
|
||||
|
||||
private Vector2 GetHitReactionVelocity(Vector2 hitVelocity)
|
||||
{
|
||||
// Airborne follow-up hits pop the enemy with a fixed Y velocity for stable combos.
|
||||
if (_hitReactionTimer <= 0f || _isGrounded)
|
||||
return hitVelocity;
|
||||
// 공중 추가타는 고정된 세로 속도를 쓰되, 이전 물리 속도는 절대 이어받지 않는다.
|
||||
Vector2 nextVelocity = hitVelocity;
|
||||
if (!_isGrounded)
|
||||
nextVelocity.y = _airborneHitYVelocity;
|
||||
|
||||
Vector2 currentVelocity = _rb.linearVelocity;
|
||||
Vector2 nextVelocity = hitVelocity == Vector2.zero ? currentVelocity : hitVelocity;
|
||||
nextVelocity.y = _airborneHitYVelocity;
|
||||
return nextVelocity;
|
||||
}
|
||||
|
||||
@@ -141,7 +144,7 @@ private void UpdateGroundedState(Collision2D collision)
|
||||
|
||||
private void BounceOffWall(Vector2 wallNormal)
|
||||
{
|
||||
// While in hit reaction, side-wall impacts reflect the current knockback.
|
||||
// 피격 반응 중 옆벽에 부딪히면 현재 넉백 속도를 반사한다.
|
||||
Vector2 incomingVelocity = _lastVelocity.sqrMagnitude > _rb.linearVelocity.sqrMagnitude
|
||||
? _lastVelocity
|
||||
: _rb.linearVelocity;
|
||||
|
||||
Reference in New Issue
Block a user