修复 Knife 武器攻击动画位置错误

This commit is contained in:
2026-09-27 16:05:07 +08:00
parent 91b8e177c5
commit 4ac79f0101
2 changed files with 27 additions and 11 deletions
@@ -39,15 +39,37 @@ namespace SepCore.Entity
_isAttacking = true;
Transform parentTransform = CachedTransform.parent;
_attackParent = parentTransform;
_attackCenter = _target != null ? _target.CachedTransform.position : CachedTransform.position;
Vector3 startPos = CachedTransform.position;
Vector3 targetPos;
if (_target != null && _target.Available)
{
targetPos = _target.CachedTransform.position;
targetPos.y = startPos.y;
Vector3 delta = targetPos - startPos;
float maxRange = CurrentAttackRange;
if (delta.sqrMagnitude > maxRange * maxRange)
{
targetPos = startPos + delta.normalized * maxRange;
}
}
else
{
targetPos = startPos + CachedTransform.forward * CurrentAttackRange;
}
_attackCenter = _target != null && _target.Available ? _target.CachedTransform.position : targetPos;
CachedTransform.SetParent(null);
Vector3 targetPos = CachedTransform.position + CachedTransform.forward * CurrentAttackRange;
_attackSequence = DOTween.Sequence();
_attackSequence.Append(CachedTransform.DOMove(targetPos, _attackDuration).SetEase(Ease.OutQuad));
_attackSequence.AppendCallback(() =>
{
_attackEffect.Play(this, _attackCenter, null, HitRadius);
Vector3 hitPoint = _target != null && _target.Available ? _target.CachedTransform.position : targetPos;
_attackCenter = hitPoint;
_attackEffect.Play(this, _attackCenter, _target, HitRadius);
ApplyGroundAreaDamage();
if (_attackParent != null)
{
@@ -74,8 +96,6 @@ namespace SepCore.Entity
return;
}
if (_hitResults == null || _hitResults.Length == 0) return;
int hitCount = Physics.OverlapSphereNonAlloc(_attackCenter, radius, _hitResults, _hitMask,
QueryTriggerInteraction.Collide);