NavMesh Agent
を使用して、異なるウェイポイントにパトロールする敵を持っています。敵が次のウェイポイントに到達してそのウェイポイントと同じ回転をしたいときに欲しいです。 ここのコードです:NavMeshエージェントオーバーライド
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();
}
}
}
問題は、彼は非常に迅速に前後に回転し続けていることですが、私は私が欲しいtehの所望の効果を得ることができません。動作するはず
:
いいえ、それは何もしませんでした。 – Abdou023
私の投稿を編集しました。これを試してみてください。 – Woltus
それは完璧に働いた。ありがとう。 – Abdou023