Im Trying to Make a Terrian Paint Brush but i get a error
UnityException: Trying to access out-of-bounds terrain height information.
public class TerrianBrush : MonoBehaviour {
public Vector3 brushPostion;
public float[,] lastHight;
public Ray ray;
public RaycastHit hit;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
ray = camera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast (ray,out hit)) {
brushPostion = hit.point;
}
GameObject.Find("Brush").transform.position = brushPostion;
if (Input.GetMouseButton(0)) {
lastHight = Terrain.activeTerrain.terrainData.GetHeights(Mathf.RoundToInt(brushPostion.x), Mathf.RoundToInt(brushPostion.y),10,10);
}
}
}