Created
September 4, 2019 18:52
-
-
Save kleberandrade/27609e5afdc3ceea6bd75ba43ce9727b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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