Class WanderState
Wandering behaviour. The NPC drifts to random points around its home, pausing at idle now and then.
[CreateAssetMenu(fileName = "New AI Wander State", menuName = "FishMMO/Character/NPC/AI/Wander State", order = 0)]
public class WanderState : BaseAIState, ICachedObject
- Inheritance
-
ObjectScriptableObjectWanderState
- 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
Remarks
For a pet, Home is its owner, so the same state produces "mill about near the player" without any pet-specific code.
Fields
AlwaysPickNewDestination
If true, the NPC picks a new destination on every update instead of walking to the current one.
public bool AlwaysPickNewDestination
Field Value
IdleChance
Chance (0-1) of standing idle instead of picking another destination on arrival.
[Range(0, 1)]
[Tooltip("Chance to pause at idle on arrival instead of wandering on.")]
public float IdleChance
Field Value
MaxUpdateRate
If greater than the base update rate, the update rate is randomized between the two.
[Tooltip("If max update rate is greater than the update rate it will return a random range between the two.")]
public float MaxUpdateRate
Field Value
WanderRadius
The radius within which the NPC will wander from its home position.
public float WanderRadius
Field Value
Methods
Enter(AIController)
Sets off toward a first destination.
public override void Enter(AIController controller)
Parameters
controllerAIControllerThe AI controller managing this NPC.
Remarks
Entering used to do nothing at all, leaving the NPC pathless until UpdateState happened to notice — and the check it used to notice with could not distinguish "no path" from "arrived".
Exit(AIController)
Called when the state is exited.
public override void Exit(AIController controller)
Parameters
controllerAIControllerThe AI controller managing this NPC.
GetUpdateRate(AIController)
Returns the update rate for this state, randomized when MaxUpdateRate exceeds the base rate.
public override float GetUpdateRate(AIController controller)
Parameters
controllerAIControllerThe AI controller running this state.
Returns
- float
Update rate in seconds.
UpdateState(AIController, float)
Walks to the current destination, then decides whether to idle or wander on.
public override void UpdateState(AIController controller, float deltaTime)
Parameters
controllerAIControllerThe AI controller managing this NPC.
deltaTimefloatSeconds since the previous AI tick.