August 2018
Beginner
334 pages
10h 19m
English
We will develop our terrain generator in just a single component:
using UnityEngine;public class TerrainGenerator : MonoBehaviour{ // next steps}
[Range(3, 101)]public int size;[Range(0.1f, 20f)]public float maxHeight;protected float[,] terrain;
public void Init(){ if (size % 2 == 0) size++; terrain = new float[size, size]; terrain[0, 0] = Random.value; terrain[0, size-1] = Random.value; terrain[size-1, 0] = Random.value; terrain[size-1, size-1] = Random.value;}
Read now
Unlock full access