- TargetSurfaceUtility를 추가해 플레이어와 적의 실제 충돌 표면 기준으로 거리, 방향, 목적지를 계산 - 플레이어 이동과 적 루트모션, 추적 로직에서 접촉 시 수평 이동을 제한해 겹침과 밀어내기 문제를 완화 - 드로그 AI 거리 판정 노드들이 표면 거리 기준을 사용하도록 맞춰 사거리 분기 오차를 줄임
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using Unity.Behavior;
|
|
using Unity.Properties;
|
|
using Condition = Unity.Behavior.Condition;
|
|
using Colosseum.Enemy;
|
|
|
|
namespace Colosseum.AI.BehaviorActions.Conditions
|
|
{
|
|
/// <summary>
|
|
/// 체력이 지정된 비율 이하인지 확인합니다.
|
|
/// </summary>
|
|
[Serializable, GeneratePropertyBag]
|
|
[Condition(name: "Is Health Below", story: "체력이 [HealthPercent]% 이하인가?", id: "7a4ce4b7-9344-4589-b744-11f5d846dcb2")]
|
|
[NodeDescription(name: "Is Health Below", story: "Check if health is below [HealthPercent] percent", category: "Combat")]
|
|
public partial class IsHealthBelowCondition : Condition
|
|
{
|
|
[SerializeReference]
|
|
public BlackboardVariable<float> HealthPercent = new BlackboardVariable<float>(50f);
|
|
|
|
public override bool IsTrue()
|
|
{
|
|
EnemyBase enemy = GameObject.GetComponent<EnemyBase>();
|
|
|
|
if (enemy == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
float currentHealthPercent = (enemy.CurrentHealth / enemy.MaxHealth) * 100f;
|
|
return currentHealthPercent <= HealthPercent.Value;
|
|
}
|
|
}
|
|
}
|