public void OnEnable() { mapLocation = GameObject.Find("Main Camera").GetComponent <HeuristicMap>(); float xpos = transform.localPosition.x + mapLocation.fieldLength / 2; float ypos = transform.localPosition.y + mapLocation.fieldHeight / 2; float heuristic = mapLocation.nodeHeuristic[(int)xpos, (int)ypos]; if (heuristic != 0f) { Vector2 destination = nextMove((int)xpos, (int)ypos); mapLocation.pathFind(destination, transform.parent.transform); } }
public void pathHere() { mapLocation.pathFind(transform.localPosition, transform.parent); }