// Recalc the List of Vector3 to follow to target void RecalculatePath(StateController controller) { // First find grid and sanity check GameObject grid = GameObject.Find("Grid"); if (grid == null) { Debug.LogError("Couldn't find Grid in SeekAction"); return; } // Second find the controller and sanity check GridController gridController = grid.GetComponent <GridController> (); if (gridController == null) { Debug.LogError("Couldn't find GridController in SeekAction"); return; } gridController.ResetColors(); // Then calculate the path controller.path = gridController.AStar(controller.gameObject, controller.target); if (controller.path == null) { Debug.LogError("No path found"); } else { controller.targetNode = controller.path [0]; } }