// Update is called once per frame void Update() { if (transform.position == path.target.position) { changeTarget = true; } if (changeTarget) { FindTarget(); changeTarget = false; path.ClearVisited(); } }