2026-05-18 부자연스러운 모션
This commit is contained in:
@@ -37,6 +37,9 @@ public class Enemy : MonoBehaviour, IDamageable
|
||||
private float _hitPositionCorrectionDuration;
|
||||
private Vector2 _hitPositionCorrectionStart;
|
||||
private Vector2 _hitPositionCorrectionTarget;
|
||||
private bool _isGrabbed;
|
||||
private Vector2 _grabTargetPosition;
|
||||
private int _grabSolidMask;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -66,6 +69,14 @@ private void FixedUpdate()
|
||||
{
|
||||
if (_rb != null)
|
||||
{
|
||||
if (_isGrabbed)
|
||||
{
|
||||
_rb.linearVelocity = Vector2.zero;
|
||||
_rb.MovePosition(_grabTargetPosition);
|
||||
_lastVelocity = Vector2.zero;
|
||||
return;
|
||||
}
|
||||
|
||||
ApplySmoothHitPositionCorrection();
|
||||
_lastVelocity = _rb.linearVelocity;
|
||||
}
|
||||
@@ -75,6 +86,8 @@ public void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReac
|
||||
{
|
||||
if (_currentHealth <= 0) return;
|
||||
|
||||
_isGrabbed = false;
|
||||
|
||||
_currentHealth -= amount;
|
||||
Debug.Log($"{name} 피격: -{amount} (HP: {_currentHealth}/{_maxHealth})");
|
||||
|
||||
@@ -109,6 +122,39 @@ public void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReac
|
||||
Die();
|
||||
}
|
||||
|
||||
public void BeginGrab(string grabbedAnimationState, int solidMask)
|
||||
{
|
||||
if (_currentHealth <= 0) return;
|
||||
|
||||
_isGrabbed = true;
|
||||
_grabSolidMask = solidMask;
|
||||
_isHitPositionCorrecting = false;
|
||||
_hitReactionTimer = 0f;
|
||||
_lastVelocity = Vector2.zero;
|
||||
|
||||
if (_rb != null)
|
||||
{
|
||||
_rb.linearVelocity = Vector2.zero;
|
||||
_grabTargetPosition = _rb.position;
|
||||
}
|
||||
|
||||
if (_anim != null && !string.IsNullOrEmpty(grabbedAnimationState))
|
||||
_anim.Play(grabbedAnimationState);
|
||||
}
|
||||
|
||||
public void UpdateGrabPosition(Vector2 position)
|
||||
{
|
||||
if (!_isGrabbed || _rb == null) return;
|
||||
|
||||
_rb.linearVelocity = Vector2.zero;
|
||||
_grabTargetPosition = GetSafeHitTargetPosition(position, _grabSolidMask);
|
||||
}
|
||||
|
||||
public void EndGrab()
|
||||
{
|
||||
_isGrabbed = false;
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
UpdateGroundedState(collision);
|
||||
|
||||
Reference in New Issue
Block a user