public override void OnInspectorGUI() { PatrolPath path = (PatrolPath)target; //Add a button that will add new waypoints if (GUILayout.Button("Add Waypoint")) { //Call Start() on the path so its waypoint data is initialised path.Start(); //Create the new object to house our waypoint GameObject newWaypoint = new GameObject(); newWaypoint.name = "Waypoint" + path.Size(); newWaypoint.transform.parent = path.transform; newWaypoint.transform.localPosition = Vector3.zero; //Create the waypoint component instance PatrolPathWaypoint waypoint = newWaypoint.AddComponent <PatrolPathWaypoint>(); waypoint.orderInSequence = path.Size(); //Add it to the path! path.AddWaypoint(waypoint); } }
// Update is called once per frame public void UpdateMovement() { if (sleepingCounter > 0) { sleepingCounter -= Time.deltaTime; } if (patrolPath != null && patrolPath.Size() > 0 && sleepingCounter <= 0 && IsWaypointReachable(patrolPath[pathIndex])) { FollowPath(); } else if (sleepingCounter <= 0) { WalkToEdges(); } }