Ok so I have this code:
using UnityEngine;
using System.Collections;
public class TerrainEditing : MonoBehaviour {
private Ray ray;
private RaycastHit hit;
public Terrain terrain;
void Update () {
if (Input.GetMouseButtonDown(0))
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 100))
{
Vector3 pos = hit.point;
terrain.terrainData.SetHeights((int)pos.x, (int)pos.y, new float[100,100]);
}
}
}
}
But for some reason, this doesn’t work! I just want to click anywhere on the terrain and have it raise to what height I want.
Can anyone see something wrong with this code?
Thanks,
Alex