private void OnDrawGizmos() { Transform[] children = PPPUtil.GetAllChildren(transform); for (int i = 0; i < children.Length - 1; i++) { Gizmos.color = new Color(0f, 255f, 0f); Gizmos.DrawLine(children[i].position, children[i + 1].position); } }
public Vector3[] GetPathToWaitingZone() { float xPos = Random.Range(waitArea.min.x, waitArea.max.x); float zPos = Random.Range(waitArea.min.z, waitArea.max.z); Vector3 posInWaitZone = new Vector3(xPos, 0f, zPos); spawnToWaitingZone.path[spawnToWaitingZone.path.Length - 1].position = posInWaitZone; Vector3[] path = PPPUtil.Transforms2Positions(spawnToWaitingZone.path); return(path); }
public Vector3[] GetPathToExit(int stationIndex) { if (stationIndex > 0) { treatmentStations[stationIndex].isOccupied = false; return(PPPUtil.Transforms2Positions(treatmentStations[stationIndex].stationToExit.path)); } else { Vector3[] exit = { treatmentStations[0].stationToExit.path[treatmentStations[0].stationToExit.path.Length - 1].position }; return(exit); } }
public int TryGetStation(out Vector3[] path) { for (int i = 0; i < treatmentStations.Length; i++) { if (!treatmentStations[i].isOccupied) { path = PPPUtil.Transforms2Positions(treatmentStations[i].spawnToStation.path); treatmentStations[i].isOccupied = true; return(i); // returns station index } } path = null; return(-1); }
IEnumerator RunFollowPath(Vector3[] path) { for (int i = 0; i < path.Length;) { Vector3 toTarget = PPPUtil.ToTargetVecXZ(transform.position, path[i]); if (toTarget.magnitude > .05f) { rb.velocity = toTarget.normalized * moveSpeed; } else { i++; } yield return(null); } PerformNextTask(); }
public Transform[] path; // Real path public void UpdatePath() { path = PPPUtil.GetAllChildren(transform); }