Question by
unity_Kdy9UQmowVILsQ · Oct 04, 2020 at 02:29 PM ·
2d gamechunks
I cant get this to work
@unity using System.Collections; using System.Collections.Generic; using UnityEngine;
public class GenarateChunk : MonoBehaviour { public GameObject DirtTile; public GameObject Grasstile; public GameObject StoneTile;
public int width;
public float heightMultiplier;
// Start is called before the first frame update
void Start()
{
Generate();
}
public void Generate() { for (int i = 0; i < width; i++) { int h = Mathf.RoundToInt(Mathf.PerLimit(0f, 1 / 3));
for (int j = 0; j < h; j++)
{
GameObject selectedTile;
if(j < h - 4)
{
selectedTile = StoneTile;
} else if (j < h - 1)
{
selectedTile = DirtTile;
} else
{
selectedTile = Grasstile;
}
instantiate(selectedTile, new Vector3(i, j), Quanternion.identity);
}
}
}
}
it doesn't work I'm doing a 2d game based on terraria and the chunk command isn't working. Thx
Comment