2026-05-18 애니메이션 설계 수정
This commit is contained in:
@@ -10,7 +10,6 @@ public class ActionData : ScriptableObject
|
||||
public string AnimationState;
|
||||
public float AnimationSpeed = 1f;
|
||||
public AnimationCurve AnimationSpeedCurve = AnimationCurve.Linear(0f, 1f, 1f, 1f);
|
||||
public bool ReturnToIdleOnAnimationComplete;
|
||||
public float Cooldown = 0.3f;
|
||||
public float ComboWindow = 0.25f;
|
||||
|
||||
@@ -36,5 +35,9 @@ public class ActionData : ScriptableObject
|
||||
|
||||
[Header("Hit Reaction")]
|
||||
public Vector2 HitVelocity = Vector2.zero;
|
||||
public bool UseHitPositionCorrection;
|
||||
public Vector2 HitTargetOffset = new Vector2(0.8f, 0f);
|
||||
public float HitPositionCorrectionDuration = 0.08f;
|
||||
public bool CorrectHitTargetY;
|
||||
public string HitReactionAnimationState;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
public interface IDamageable
|
||||
{
|
||||
void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReactionAnimationState = null);
|
||||
void TakeDamage(int amount, Vector2 hitVelocity = default, string hitReactionAnimationState = null, Vector2? hitTargetPosition = null, bool correctHitTargetY = false, int hitPositionSolidMask = 0, float hitPositionCorrectionDuration = 0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user