feat: 플레이어 다운/넉백 피격 반응 추가
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
using Colosseum.Player;
|
||||
|
||||
namespace Colosseum.Skills.Effects
|
||||
{
|
||||
/// <summary>
|
||||
@@ -11,6 +13,7 @@ namespace Colosseum.Skills.Effects
|
||||
[Header("Knockback Settings")]
|
||||
[Min(0f)] [SerializeField] private float force = 5f;
|
||||
[SerializeField] private float upwardForce = 2f;
|
||||
[Min(0.05f)] [SerializeField] private float duration = 0.2f;
|
||||
|
||||
protected override void ApplyEffect(GameObject caster, GameObject target)
|
||||
{
|
||||
@@ -18,13 +21,23 @@ namespace Colosseum.Skills.Effects
|
||||
|
||||
Vector3 direction = target.transform.position - caster.transform.position;
|
||||
direction.y = 0f;
|
||||
direction.Normalize();
|
||||
if (direction.sqrMagnitude <= 0.0001f)
|
||||
direction = caster.transform.forward;
|
||||
else
|
||||
direction.Normalize();
|
||||
|
||||
Vector3 knockback = direction * force + Vector3.up * upwardForce;
|
||||
Vector3 knockbackVelocity = direction * force + Vector3.up * upwardForce;
|
||||
|
||||
// TODO: 실제 물리 시스템 연동
|
||||
// if (target.TryGetComponent<Rigidbody>(out var rb))
|
||||
// rb.AddForce(knockback, ForceMode.Impulse);
|
||||
if (target.TryGetComponent<HitReactionController>(out var hitReactionController))
|
||||
{
|
||||
hitReactionController.ApplyKnockback(knockbackVelocity, duration);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.TryGetComponent<PlayerMovement>(out var playerMovement))
|
||||
{
|
||||
playerMovement.ApplyForcedMovement(knockbackVelocity, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user