Class PatrolState
Waypoint patrol. Walks the spawner-supplied waypoint ring in order.
[CreateAssetMenu(fileName = "New AI Patrol State", menuName = "FishMMO/Character/NPC/AI/Patrol State", order = 0)]
public class PatrolState : BaseAIState, ICachedObject
- Inheritance
-
ObjectScriptableObjectPatrolState
- Implements
- Inherited Members
-
ScriptableObject.SetDirty()ScriptableObject.CreateInstance<T>()Object.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Fields
MaxSkippedWaypoints
Consecutive unreachable waypoints tolerated before the NPC gives up on patrolling.
[Tooltip("Consecutive unreachable waypoints before the NPC abandons its patrol.")]
public int MaxSkippedWaypoints
Field Value
Remarks
Guards against a waypoint ring where every entry has drifted off the NavMesh: without a bound the NPC would advance through the whole ring every tick forever, never moving.
WaypointTolerance
How close the NPC must get to a waypoint before moving on to the next one.
[Tooltip("Distance from a waypoint that counts as reaching it.")]
public float WaypointTolerance
Field Value
Methods
Enter(AIController)
Starts patrolling from the nearest waypoint.
public override void Enter(AIController controller)
Parameters
controllerAIControllerThe AI controller.
Exit(AIController)
Called when exiting the Patrol state.
public override void Exit(AIController controller)
Parameters
controllerAIControllerThe AI controller.
UpdateState(AIController, float)
Advances to the next waypoint on arrival, and recovers when a waypoint cannot be reached.
public override void UpdateState(AIController controller, float deltaTime)
Parameters
controllerAIControllerThe AI controller.
deltaTimefloatSeconds since the previous AI tick.
Remarks
The previous arrival test was !pathPending && remainingDistance < 1,
which is also exactly what an agent with no path at all reports. A patrol whose first
waypoint failed to sample onto the NavMesh therefore "arrived" at every waypoint in the
ring, once per tick, without taking a single step.