Skip to content

Instantly share code, notes, and snippets.

@kleberandrade
Created September 4, 2019 18:52
Show Gist options
  • Save kleberandrade/27609e5afdc3ceea6bd75ba43ce9727b to your computer and use it in GitHub Desktop.
Save kleberandrade/27609e5afdc3ceea6bd75ba43ce9727b to your computer and use it in GitHub Desktop.
using UnityEngine;
public class MapBuilder : MonoBehaviour
{
public GameObject m_TilePrefab;
public float m_MinHeight = 0.0f;
public float m_MaxHeight = 0.05f;
public int m_Size = 20;
private void Start()
{
for (int z = 0; z < m_Size; z++)
{
for (int x = 0; x < m_Size; x++)
{
float height = Random.Range(m_MinHeight, m_MaxHeight);
Vector3 position = new Vector3(x - m_Size * 0.5f, height, z - m_Size * 0.5f);
GameObject tile = Instantiate(m_TilePrefab);
tile.transform.parent = transform;
tile.transform.position = position;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment