public virtual bool Visit(Vector2 target) { DefaultBehavior(); path = Pathfinding.CreatePath(movingEntity.transform.position, new Vector3(target.x, 1, target.y)); if (path == null) { Debug.Log("Can't visit because path cannot be found!"); pathIndex = -1; return(false); } /* * if (pathIndex <= 0) { * pathIndex = -1; * return false; * }*/ pathIndex = path.Length - 1; movingEntity.targetPos = path[pathIndex]; steeringCalculate.seek = true; return(true); }
void FindPath(Survivor_AI sAI, Vector3 startPoint, Vector3 endPoint) { List <PathNode> path = pathfinder.CreatePath(startPoint, endPoint); if (path != null) { for (int i = 0; i < path.Count; i++) { if (sAI.transform.position != path[i].transform.position) { sAI.GetSurvivor().MoveTo(path[i].transform.position); } else { // pop the current node of the list path.Remove(path[i]); } } } }