私はあなたのAI用の状態マシンを作成するためにYouTubeで利用できるUnityビデオをたどりましたが、敵がパトロール中は壁を歩いています。私は敵にRigidBodyコンポーネントを追加しようとしましたが、これはそれぞれのウェイポイントに向かう動きを完全にバグです。ここでUnity - 敵AIが壁を歩いている
は、各ウェイポイントへのAIの動き
private void Look()
{
RaycastHit hit;
if (Physics.Raycast(enemy.eyes.transform.position, enemy.eyes.transform.forward, out hit, enemy.sightRange) && hit.collider.CompareTag("Player"))
{
enemy.chaseTarget = hit.transform;
InChaseState();
}
}
void Patrol()
{
enemy.meshRendererFlag.material.color = Color.green; //Test to see what state the enemy is in
enemy.navMeshAgent.destination = enemy.waypoints[nextWaypoint].position; //Select the current waypoint
enemy.navMeshAgent.Resume(); //Start walking again
if (enemy.navMeshAgent.remainingDistance <= enemy.navMeshAgent.stoppingDistance && !enemy.navMeshAgent.pathPending) //Checking to see if we've reached our destination
{
nextWaypoint = (nextWaypoint + 1) % enemy.waypoints.Length; //Go to next waypoint and should loop as expected
}
}
は、各ウェイポイントに到達するためのマップでは、壁の周りに敵の散歩をするために、このコードを編集する方法を誰もが知っている可能コードのですか?ありがとう。
壁がNavMeshから彫られていない可能性がありますか?アルゴリズムのために壁にはコライダーが必要です。また、ナビゲーション静的(静的なチェックボックスのドロップダウンで設定することができます)または正しく覚えているときのコンポーネントであるNavMesh障害である必要があります。 – Wipster