Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. using UnityEngine;
  2. public class MapBuilder : MonoBehaviour
  3. {
  4. public GameObject m_TilePrefab;
  5. public float m_MinHeight = 0.0f;
  6. public float m_MaxHeight = 0.05f;
  7. public int m_Size = 20;
  8. private void Start()
  9. {
  10. for (int z = 0; z < m_Size; z++)
  11. {
  12. for (int x = 0; x < m_Size; x++)
  13. {
  14. float height = Random.Range(m_MinHeight, m_MaxHeight);
  15. Vector3 position = new Vector3(x - m_Size * 0.5f, height, z - m_Size * 0.5f);
  16.  
  17. GameObject tile = Instantiate(m_TilePrefab);
  18. tile.transform.parent = transform;
  19. tile.transform.position = position;
  20. }
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement