// Update is called once per frame void Update() { if (path_ == null || path_.Count == 0) { path_ = PathFinder.Instance.GetPath(transform.position, new Vector3(Random.Range(-2, 2), Random.Range(2, -2), 0)); unitMovement_.SetTargetPosition(path_[0]); } else { if (Vector3.Distance(transform.position, path_[0]) < stoppingDistance_) { path_.RemoveAt(0); if (path_.Count > 0) { unitMovement_.SetTargetPosition(path_[0]); } } } }