I want my enemy to move randomly to certain points on the scene. It moves to one point and then stops! It does not continue to the other points!
Here is my script:
using UnityEngine;
using System.Collections;
public class emove: MonoBehaviour {
NavMeshAgent ePath;
public GameObject[] POINT;
void Start () {
ePath = GetComponent<NavMeshAgent>();
}
void Update () {
foreach (GameObject waypoint in POINT) {
ePath.SetDestination(waypoint.transform.position);
ePath.speed = 2;
// I write this, if you have different idea tell me please
if (waypoint.activeSelf == false) // waypoint had it own script, when enemy touch any point it set off
{
ePath.SetDestination(waypoint.transform.position); // move to any other active waypoint.
ePath.speed = 2;
}
}
}
What am I doing wrong?