private Vector3 GetRandomSurfacePosition() { Vector3 randomPos; Vector3 terrainDimension = SurfaceManager.SurfaceDimension(); do { randomPos = new Vector3(Random.Range(0, terrainDimension.x), 0, Random.Range(0, terrainDimension.z)) + SurfaceManager.SurfacePosition(); randomPos.y = SurfaceManager.GetSurfaceHeight(surface, randomPos); } while (!CouldTreeSpawnIn(randomPos)); return(randomPos); }