플레이어 HPBar
This commit is contained in:
@@ -119,6 +119,7 @@ public class PlayerController : MonoBehaviour,IDamageable
|
||||
private Rigidbody2D _rb;
|
||||
private Animator _anim;
|
||||
private SpriteRenderer _spriteRenderer; // 좌우 반전 + flipX 페이싱용
|
||||
private Health _health;
|
||||
|
||||
// ─── 무기 시스템 ────────────────────────────────────────────────────
|
||||
// PlayerWeaponInventory가 현재 장착 무기 관리. 무기 교체 시 OnWeaponChanged 이벤트 발화.
|
||||
@@ -131,6 +132,7 @@ private void Awake()
|
||||
_rb = GetComponent<Rigidbody2D>();
|
||||
_anim = GetComponent<Animator>();
|
||||
_spriteRenderer = GetComponentInChildren<SpriteRenderer>();
|
||||
_health = GetComponent<Health>();
|
||||
ResolveBodyColliderReference();
|
||||
EnsureAttackHitbox();
|
||||
// 공격이 enemy를 hit하면 _lastHitEnemy를 기억 → 다음 잡기에서 그 enemy를 우선 타겟팅.
|
||||
@@ -1578,5 +1580,9 @@ private void DrawTimelineBar(ActionData data, float elapsed)
|
||||
|
||||
public void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReactionAnimationState = null, Vector2? hitTargetPosition = null, bool correctHitTargetY = false, int hitPositionSolidMask = 0, float hitPositionCorrectionDuration = 0)
|
||||
{
|
||||
if (_health == null || _health.IsDead) return;
|
||||
|
||||
_health.TakeDamage(amount);
|
||||
Debug.Log($"{name} 피격: -{amount} (HP: {_health.CurrentHealth}/{_health.MaxHealth})");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user