OldBlueWater/BlueWater/Assets/Behavior Designer/Runtime/Tasks/Unity/NavMeshAgent/Stop.cs
NTG 59c4b14d1a #34 #35 InIslandPlayer, Ai 2D 베이스 변경 작업
+ SPUM 프리팹 NavMeshAgent 위치 변경, 콜라이더, Agent 크기 변경
+ SPUM에서 제공되는 NormalAnimator의 공격 모션에 Event 추가
+ Ork 프리팹 UnitRoot에 Animator Bridge 추가
+ IAiView 타겟을 검색하는 Ai 인터페이스 추가
+ IHelpCall 주변 아군에게 타겟을 공유하는 인터페이스 추가
+ 기존 02.Scripts.Ai.BehaviorTree에는 그대로 냅두고,
  02.Scripts.Ai.NewBehaviorTree 폴더를 추가하여 사용
+ Enemy의 BehaviorTree인 Minion 추가
+ InIslandPlayer의 기본 이동 구현
2023-10-12 05:26:45 +09:00

44 lines
1.3 KiB
C#

using UnityEngine;
using UnityEngine.AI;
namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityNavMeshAgent
{
[TaskCategory("Unity/NavMeshAgent")]
[TaskDescription("Stop movement of this agent along its current path. Returns Success.")]
public class Stop : Action
{
[Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")]
public SharedGameObject targetGameObject;
// cache the navmeshagent component
private NavMeshAgent navMeshAgent;
private GameObject prevGameObject;
public override void OnStart()
{
var currentGameObject = GetDefaultGameObject(targetGameObject.Value);
if (currentGameObject != prevGameObject) {
navMeshAgent = currentGameObject.GetComponent<NavMeshAgent>();
prevGameObject = currentGameObject;
}
}
public override TaskStatus OnUpdate()
{
if (navMeshAgent == null) {
Debug.LogWarning("NavMeshAgent is null");
return TaskStatus.Failure;
}
navMeshAgent.isStopped = true;
navMeshAgent.enabled = false;
return TaskStatus.Success;
}
public override void OnReset()
{
targetGameObject = null;
}
}
}