void ProgressRoutine() { AIRoutine.WayPoint nextWaypoint = routine.GetNextWaypoint(); SetTask(nextWaypoint.triggerable); //the line bellow will throw errors if both triggerable and rawPosition are not set. Leaving it as it is for now until I implement a better system to manage routines. PlanAndExecuteMovement(nextWaypoint.triggerable == null? nextWaypoint.rawPosition.position : nextWaypoint.triggerable.transform.position); }
void OnGUI() { //test //list routine waypoints on GUI float rectWidth = 400.0f; float xPosition = Screen.width - rectWidth; Rect rect = new Rect(xPosition, 10, rectWidth, 30); string line = "<size=20> --- AI ROUTINE --- </size>"; GUI.Label(rect, line); for (int i = 0; i < routine.wayPoints.Length; i++) { AIRoutine.WayPoint waypoint = routine.wayPoints[i]; rect.y += rect.height + 5; if (waypoint.triggerable != null) { line = "<size=15> Triggerable: " + waypoint.triggerable.gameObject.name + ".</size>"; } else if (waypoint.rawPosition != null) { line = "<size=15> RawPosition: " + waypoint.rawPosition.gameObject.name + ".</size>"; } else { line = "<size=15> --Empty waypoint-- </size>"; } GUI.Label(rect, line); } }