/// <summary> /// Builds the graph by collecting all <see cref="Waypoint"/> game objects in the scene, /// and using their positions as the source data for <see cref="AStarNode"/>s. /// </summary> private void BuildGraph() { _waypointNodes = new Dictionary <Guid, AStarNode>(); var sceneWaypoints = GameObject.FindGameObjectsWithTag("Waypoint"); var nodes = new AStarNode[sceneWaypoints.Length]; // Create AStarNode instances for each Waypoint in the scene for (int i = 0; i < sceneWaypoints.Length; i++) { var waypoint = sceneWaypoints[i].GetComponent <Waypoint>(); var node = new AStarNode(waypoint.transform.position); nodes[i] = node; _waypointNodes.Add(waypoint.Id, node); } // Build the visibility map according to the nodes in scene _visibilityGraph = new VisibilityGraph(nodes); _visibilityGraph.Build(); }