So I’m trying to make a function that places tiles psuedorandomly in a tile map using perlin noise; problem is that whenever I call the function ‘Mathf.PerlinNoise()’ unity freezes and eventually crashes (Note: I’ve tried this with small values for ‘size’). I’ve also had this problem with simpler code in the past and in different versions of unity; am I calling it wrong perhaps or might it be my computer?
public Vector2Int size;
void changeMap(int x, int y, Tile place)
{
tileMap.SetTile(new Vector3Int(x, y, 0), place);
}
void makeLevel(int X, int Y)
{
if (Input.GetButtonDown("Jump"))
{
for (x = 0; x < X; y++)
{
for (y = 0; y < Y; y++)
{
if(Mathf.PerlinNoise(x/X, y/Y) > 0.8)
{
changeMap(x, y, tile);
}
}
}
}
}
private void Update()
{
makeLevel(size.x,size.y);
}
Update: running PerlinNoise() once is fine.