Files
Colosseum/Assets/Scripts/AI/BehaviorActions/Actions/FindTargetAction.cs
dal4segno aeb4fc2847 feat: AI 타겟팅 개선 - 사망한 대상 무시
- FindTargetAction: IDamageable.IsDead 체크로 사망한 타겟 제외
- SetTargetInRangeAction: 사망한 타겟을 거리 검색에서 제외
- HasTargetCondition: 타겟 생존 여부 추가 확인
- BossArea: FindObjectOfType → FindFirstObjectByType 변경

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-14 15:08:47 +09:00

51 lines
1.5 KiB
C#

using System;
using Unity.Behavior;
using UnityEngine;
using Action = Unity.Behavior.Action;
using Unity.Properties;
using Colosseum.Combat;
[Serializable, GeneratePropertyBag]
[NodeDescription(name: "FindTarget", story: "[타겟] ", category: "Action", id: "bb947540549026f3c5625c6d19213311")]
public partial class FindTargetAction : Action
{
[SerializeReference]
public BlackboardVariable<GameObject> Target;
[SerializeReference]
public BlackboardVariable<string> Tag = new BlackboardVariable<string>("Player");
protected override Status OnStart()
{
if (Tag.Value == null || string.IsNullOrEmpty(Tag.Value))
{
return Status.Failure;
}
// 모든 타겟 후보 검색
GameObject[] candidates = GameObject.FindGameObjectsWithTag(Tag.Value);
if (candidates == null || candidates.Length == 0)
{
return Status.Failure;
}
// 사망하지 않은 타겟 찾기
foreach (GameObject candidate in candidates)
{
IDamageable damageable = candidate.GetComponent<IDamageable>();
// IDamageable이 없거나 살아있는 경우 타겟으로 선택
if (damageable == null || !damageable.IsDead)
{
Target.Value = candidate;
return Status.Success;
}
}
// 살아있는 타겟이 없음
return Status.Failure;
}
}