I’m trying to set all the vertices of plane to match the height of the terrain. At the moment, it sets about half the plane to some random Y value and ignores the other half. I can’t seem to figure out what’s going wrong here.
So far this is what I have:
using UnityEngine;
using UnityEditor;
using System.Collections;
public class GroundVertices : MonoBehaviour
{
[MenuItem("Tools/Ground Vertices")]
static void Init()
{
Mesh m = (Mesh)((MeshFilter)Selection.activeTransform.gameObject.GetComponent(typeof(MeshFilter))).sharedMesh;
Vector3[] verts = m.vertices;
for(int i = 0; i < verts.Length; i++)
{
verts <em>= new Vector3(verts<em>.x, verts_.y + 100f, verts*.z);*_</em></em>
* RaycastHit ground = new RaycastHit();*
_ if(Physics.Raycast(verts*, Vector3.down, out ground))
{*_
* Debug.Log(ground.point.y + ground.transform.tag);*
_ verts*.y = ground.point.y;
}
} *_
* m.vertices = verts;*
* m.RecalculateNormals();*
* }*
}