SHARE
TWEET

Untitled

a guest Sep 15th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top