When I enter play mode it freezes and in task manager it shows that it keeps taking up more memory. When i initially launch play mode it starts at 10% then over 5-10 mins it will be at 80%.
The only script I have running is the one below. And this is for a 2D procedurally generated terrain
public class GenerateChunk : MonoBehaviour
{
public GameObject sand;
public GameObject sandStone;
public GameObject stone;
public int width;
public int heightMultiplier;
public int heightAddition;
public int seed;
public float smoothness;
void Start ()
{
Generate ();
seed = Random.Range (-10000, 10000);
}
void Generate ()
{
for (int i = 0; 1 < width; i++)
{
int h = Mathf.RoundToInt (Mathf.PerlinNoise (seed, i / smoothness) * heightMultiplier);
for (int j = 0; j < width; j++)
{
GameObject selectedTile;
if (j < h - 8)
{
selectedTile = stone;
} else if (j < h - 3)
{
selectedTile = sandStone;
} else
{
selectedTile = sand;
}
Instantiate (selectedTile, new Vector3 (i, j), Quaternion.identity);
}
}
}
}
↧