I use “wait action” in patrol behaviour, The character stand at a waypoint for about 3 seconds before move to next point. For performance, The update interval will be increased for AI characters at far distance or in invisible view. The wait time in “custom interval update” may be longer than in the normal update time but should not too long because it will make the AI behaviour become worse.
The custom Wait action I made as below:
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Category(“NCA”)]
public class NCA_Wait : ActionTask
{
public BBParameter waitTime = 1f;
public CompactStatus finishStatus = CompactStatus.Success;
float mStartTime;
bool mIsStarted;
//============
protected override string info
{
get { return string.Format(“Wait {0} sec.”, waitTime); }
}
//===============
//Use for initialization. This is called only once in the lifetime of the task.
//Return null if init was successfull. Return an error string otherwise
protected override string OnInit()
{
mIsStarted = false;