Nav Mesh Agent Path Status#
Navigation / Nav Mesh Agent / Nav Mesh Agent Path Status
Description#
Returns true if the current path of the Nav Mesh Agent has the chosen status
Parameters#
| Name | Description |
|---|---|
| Nav Mesh Agent | The Nav Mesh Agent component checked |
| Status | Complete reaches the destination, Partial stops at the closest point found and Invalid has no path |
Code#
using System;
using UnityEngine;
using UnityEngine.AI;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Nav Mesh Agent Path Status")]
[Category("Navigation/Nav Mesh Agent/Path Status")]
[Description("Returns true if the current path of the Nav Mesh Agent has the chosen status")]
[Image(typeof(IconNavmeshAgent), ColorTheme.Type.Red)]
[Keywords("Navigation", "NavMesh", "AI", "Agent", "Path", "Complete", "Partial", "Invalid")]
[Parameter("Nav Mesh Agent", "The Nav Mesh Agent component checked")]
[Parameter("Status", "Complete reaches the destination, Partial stops at the closest point found and Invalid has no path")]
[Serializable]
public class ConditionNavMeshAgentPathStatus : Condition
{
[SerializeField] private GetGameObject m_NavMeshAgent = new GetGameObject(
new GenTypeGameObject_NavMeshAgent()
);
[SerializeField] private NavMeshPathStatus m_Status = NavMeshPathStatus.PathComplete;
protected override string GetTitle(GameObject source)
{
string member = TextUtils.ThemeAsKeyword("Path Status");
return $"{this.m_NavMeshAgent} {member} is {this.m_Status}";
}
protected override bool Run(Args args)
{
NavMeshAgent agent = this.m_NavMeshAgent.Get<NavMeshAgent>(args);
return agent != null && agent.pathStatus == this.m_Status;
}
}
}