public void DrawPresetPath(PathList path, Vector3 startPos) { Transform[] pathPoints = path.GetPoints(); for (int i = 0; i < pathPoints.Length;i++) { Vector3 currentPosition = pathPoints[i].position; SplitPoint split = pathPoints[i].GetComponent<SplitPoint>(); PersonPoint person = pathPoints[i].GetComponent<PersonPoint>(); if (person != null) { person.SetInfo(person.transform.position,(pathPoints[i+1].position-person.transform.position).normalized); SendMessageUpwards("MakePeople",person); } if (split != null) { foreach (PathList newPath in split.newPaths) { DrawPresetPath(newPath,startPos); } } else if (i != pathPoints.Length - 1) { Vector3 nextPosition = pathPoints[i+1].position; float initialDistance = Vector3.Distance(currentPosition, nextPosition); float numTiles = Mathf.Ceil(initialDistance/tileStep); for (int t = 0; t < numTiles; t++) { PathTile newTile = (PathTile)Instantiate(tilePrefab,currentPosition,tilePrefab.transform.rotation); currentPosition = currentPosition + ((nextPosition - currentPosition).normalized * tileStep); newTile.transform.LookAt(currentPosition, Vector3.up); newTile.transform.parent = _newPathGO.transform; } } } }