NavMesh Agent
当敌人到达下一个航路点以与该航路点具有相同的旋转时,我有敌人使用我想要的巡逻到不同的航路点。这是代码:
void Update ()
{
if (agent.remainingDistance < 0.1)
{
// tried to stop the agent so I can override it's rotation, doesn't work
agent.Stop();
// Give him the desired rotation
transform.rotation = wayPoints[curretPoint].rotation;
if (curretPoint < wayPoints.Length -1)
{
curretPoint++;
}
else
{
curretPoint = 0;
}
// make him wait for a fixed amount of time
patrolTimer += Time.deltaTime;
if (patrolTimer >= patrolWait)
{
patrolTimer = 0;
agent.SetDestination (wayPoints[curretPoint].position);
agent.Resume ();
}
}
}
问题是他一直在快速地来回旋转,我无法得到我想要的效果。