I need to flatten the terrain of an object at the start when it is activated/instantiated into the scene. I want to use a specific box collider to do it.
So basically, how would I flatten the terrain within this collider?
Here is the script so far.
//Collider.
public Collider boundsCollider;
void Start () {
//Flatten ground around before starting the bitch up..
//Cast ray down to check and get terrain.
Vector3 dRayDir = transform.TransformDirection(new Vector3(0,-100,0));
Ray dRay = new Ray(transform.position, dRayDir);
RaycastHit dhit;
if(Physics.Raycast(dRay, out dhit, Mathf.Infinity)){
var terrain = dhit.transform.GetComponent<Terrain>();
}
//So what to do with the collider and how to access the tiles(points?) on the terrain within said collider?..
}
Help… thanks.