【发布时间】:2017-05-11 23:08:04
【问题描述】:
我有敌人使用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 ();
}
}
}
问题是他一直在快速地来回旋转,我无法得到我想要的效果。
【问题讨论】: