2026-05-18 애니메이션 설계 수정
This commit is contained in:
@@ -7,6 +7,12 @@ public class AttackHitbox : MonoBehaviour
|
||||
private CircleCollider2D _collider;
|
||||
private int _damage;
|
||||
private Vector2 _hitVelocity;
|
||||
private Vector2 _hitSourcePosition;
|
||||
private Vector2? _hitTargetPosition;
|
||||
private float _hitPositionMinDistance;
|
||||
private bool _correctHitTargetY;
|
||||
private int _hitPositionSolidMask;
|
||||
private float _hitPositionCorrectionDuration;
|
||||
private string _hitReactionState;
|
||||
private LayerMask _targetLayer;
|
||||
private readonly HashSet<IDamageable> _alreadyHit = new();
|
||||
@@ -19,12 +25,18 @@ private void Awake()
|
||||
_collider.enabled = false;
|
||||
}
|
||||
|
||||
public void Activate(ActionData data, Vector2 localPosition, Vector2 hitVelocity, LayerMask targetLayer)
|
||||
public void Activate(ActionData data, Vector2 localPosition, Vector2 hitVelocity, Vector2 sourcePosition, Vector2? hitTargetPosition, bool correctHitTargetY, int hitPositionSolidMask, LayerMask targetLayer)
|
||||
{
|
||||
transform.localPosition = localPosition;
|
||||
_collider.radius = data.Radius;
|
||||
_damage = data.Damage;
|
||||
_hitVelocity = hitVelocity;
|
||||
_hitSourcePosition = sourcePosition;
|
||||
_hitTargetPosition = hitTargetPosition;
|
||||
_hitPositionMinDistance = Mathf.Abs(data.HitTargetOffset.x);
|
||||
_correctHitTargetY = correctHitTargetY;
|
||||
_hitPositionSolidMask = hitPositionSolidMask;
|
||||
_hitPositionCorrectionDuration = data.HitPositionCorrectionDuration;
|
||||
_hitReactionState = data.HitReactionAnimationState;
|
||||
_targetLayer = targetLayer;
|
||||
_alreadyHit.Clear();
|
||||
@@ -61,6 +73,20 @@ private void TryDamage(Collider2D other)
|
||||
if (_alreadyHit.Contains(target)) return;
|
||||
|
||||
_alreadyHit.Add(target);
|
||||
target.TakeDamage(_damage, _hitVelocity, _hitReactionState);
|
||||
Vector2? targetPosition = GetCorrectionTargetPosition(other);
|
||||
target.TakeDamage(_damage, _hitVelocity, _hitReactionState, targetPosition, _correctHitTargetY, _hitPositionSolidMask, _hitPositionCorrectionDuration);
|
||||
}
|
||||
|
||||
private Vector2? GetCorrectionTargetPosition(Collider2D other)
|
||||
{
|
||||
if (!_hitTargetPosition.HasValue) return null;
|
||||
if (_hitPositionMinDistance <= 0.001f) return null;
|
||||
|
||||
Vector2 currentPosition = other.attachedRigidbody != null
|
||||
? other.attachedRigidbody.position
|
||||
: (Vector2)other.transform.root.position;
|
||||
float currentDistance = Mathf.Abs(currentPosition.x - _hitSourcePosition.x);
|
||||
|
||||
return currentDistance < _hitPositionMinDistance ? _hitTargetPosition : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user