- HitReactionController에 경직, 다운 회복 가능 구간, Hit 속도 배율 파라미터 처리를 추가 - DownBegin/Recover 상태 종료를 StateMachineBehaviour로 받아 구르기 허용 구간과 다운 해제를 분리 - 드로그 발구르기를 경직 이펙트로 전환하고 넉백/경직 이펙트에서 Hit 애니메이션 속도 배율을 설정 가능하게 정리 - PlayMode 테스트를 추가해 경직/넉백이 Hit 애니메이션 속도 배율을 실제로 반영하는지 자동 검증
59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
using UnityEngine;
|
|
|
|
using Colosseum.Player;
|
|
|
|
namespace Colosseum.Skills.Effects
|
|
{
|
|
/// <summary>
|
|
/// 넉백 효과
|
|
/// </summary>
|
|
[CreateAssetMenu(fileName = "KnockbackEffect", menuName = "Colosseum/Skills/Effects/Knockback")]
|
|
public class KnockbackEffect : SkillEffect
|
|
{
|
|
[Header("Knockback Settings")]
|
|
[Min(0f)] [SerializeField] private float force = 5f;
|
|
[SerializeField] private float upwardForce = 2f;
|
|
[Min(0.05f)] [SerializeField] private float duration = 0.2f;
|
|
|
|
[Header("Hit Animation")]
|
|
[Tooltip("넉백 적용 시 경직 애니메이션 재생 여부")]
|
|
[SerializeField] private bool playHitAnimation = true;
|
|
|
|
[Tooltip("경직 애니메이션 재생 속도 배율")]
|
|
[Min(0.01f)] [SerializeField] private float hitAnimationSpeedMultiplier = 1f;
|
|
|
|
protected override void ApplyEffect(GameObject caster, GameObject target)
|
|
{
|
|
if (target == null || caster == null) return;
|
|
|
|
Vector3 direction = target.transform.position - caster.transform.position;
|
|
direction.y = 0f;
|
|
if (direction.sqrMagnitude <= 0.0001f)
|
|
direction = caster.transform.forward;
|
|
else
|
|
direction.Normalize();
|
|
|
|
Vector3 knockbackVelocity = direction * force + Vector3.up * upwardForce;
|
|
|
|
HitReactionController hitReactionController = target.GetComponent<HitReactionController>();
|
|
if (hitReactionController == null)
|
|
hitReactionController = target.GetComponentInParent<HitReactionController>();
|
|
|
|
if (hitReactionController != null)
|
|
{
|
|
hitReactionController.ApplyKnockback(knockbackVelocity, duration, playHitAnimation, hitAnimationSpeedMultiplier);
|
|
return;
|
|
}
|
|
|
|
PlayerMovement playerMovement = target.GetComponent<PlayerMovement>();
|
|
if (playerMovement == null)
|
|
playerMovement = target.GetComponentInParent<PlayerMovement>();
|
|
|
|
if (playerMovement != null)
|
|
{
|
|
playerMovement.ApplyForcedMovement(knockbackVelocity, duration);
|
|
}
|
|
}
|
|
}
|
|
}
|