void OnTriggerEnter() { // get the Track Controller GameObject TrackController = GameObject.Find("TrackController"); roadStructure rs = TrackController.GetComponent <roadStructure>(); // get the Navigation Controller GameObject navController = GameObject.Find("NavigationController"); navigationManager nav = navController.GetComponent <navigationManager>(); roadController rc = TrackController.GetComponent <roadController>(); // Shift the road generation to our alternate path. rc.setTrackSegment02(parentSegment); // Dump the current navigation and set it to start with our new path. nav.initializeDirections(); foreach (GameObject trackSegment in trackSegments) { nav.queDirection(trackSegment.GetComponent <Direction>()); } nav.displayNextDirection(); // Generate the next set of track on the alt path. rc.GenerateTrack(rc.TrackLength); // Mark that we've reached this segment for the car reset functionality. passed = true; rs.setLastSegmentPassed(parentSegment); // We're done with this trigger...shut it off. gameObject.GetComponent <BoxCollider>().enabled = false; }
void LoadNextSegment() { if (TrackSegment02 != null) { // Make the 2nd track segment into the 1st track segment TrackSegment01 = TrackSegment02; // instantiate a new track segment at the same position as Segment 01, and assign as Track Segment 02 TrackSegment02 = CreateTrackSegment(TrackSegment01); // move the new track segment so it connects with the end of the previous track segment OverlayTrackSegments(TrackSegment01, TrackSegment02); } else { // instantiate a new track segment at the same position as Segment 01, and assign as Track Segment 02 TrackSegment02 = CreateTrackSegment(TrackSegment01); // move the new track segment so it connects with the end of the previous track segment OverlayTrackSegments(TrackSegment01, TrackSegment02); } // add directions from this segment to the navigation queue nav.queDirection(TrackSegment02.GetComponent <Direction>()); }