Hello I am making a 2d Isometric management game. When customers enter the restaurant I want them to either head towards the front registers or go to the vending machine. I am able to make the customers walk to the door but I do not know how to make them seek out the next way point. I am also unable to get them to navigate around objects or choose between a random point that I set. Its kind of difficult to explain so here’s some visual aid.
[20956-point+explanation.jpg|20956]
var waypoints : Transform;
var waypoint : Transform;
var speed : int;
var currentWaypoint : int;
var agent : NavMeshAgent;
var isMoving : boolean = false;
var customer : GameObject;
function Update () {
waypoint = waypoints[currentWaypoint];
if (isMoving == true){ // sets the active waypoint to the next currentwaypoint
agent.SetDestination(waypoint.position);
}
}
function OnTriggerEnter (other : Collider) {
if (other.tag == "Waypoint"){
currentWaypoint++;
}
if (currentWaypoint == 5){
Destroy(gameObject);
}
if (other.tag == "Waypoint" && currentWaypoint == 2){
currentWaypoint = Random.Range(2, 4);
}
}
function WaitAtPoint(){
isMoving = false;
yield WaitForSeconds(5);
}
After not being able to really find a definitive answer online I created my own script.