|
|
|
|
|
|
{ |
|
|
|
_agent = agent; |
|
|
|
_isActiveAgent = _agent != null && _agent.isActiveAndEnabled && _agent.isOnNavMesh; |
|
|
|
_wayPointIndex = _wayPointIndex - 1; //Initialized to this value so we keep the right order from the waypoints list using the modulo method below
|
|
|
|
_wayPointIndex = - 1; //Initialized to -1 so we don't skip the first element from the waypoint list
|
|
|
|
_roamingSpeed = config.Speed; |
|
|
|
_wayppoints = config.Waypoints; |
|
|
|
} |
|
|
|
|
|
|
_wayPointIndex = (_wayPointIndex + 1) % _wayppoints.Count; |
|
|
|
nextDestination = _wayppoints[_wayPointIndex].waypoint; |
|
|
|
} |
|
|
|
//Debug.Log("the next destination" + nextDestination);
|
|
|
|
//Debug.Log("the next destination index = " +_wayPointIndex + "value = " + nextDestination);
|
|
|
|
return nextDestination; |
|
|
|
} |
|
|
|
} |