GameObject SpawnRandomWaypoint() { if (startPosGenerator == null) { startPosGenerator = FindObjectOfType <StartPositionGenerator>(); } Transform newWaypointTransform = Instantiate(waypointPrefab, startPosGenerator.GeneratePositionInRandomSpawnZone(), startPosGenerator.GenerateRandomRotation()); return(newWaypointTransform.gameObject); }