# Changing Y Value in Vertex Array?

I was working from a tutorial on procedural mesh generation, and I decided to try something out. I wanted to go through the array of points that I had created and make their Y values all 1. However, the program didn’t really seem to do anything. Here’s the program:

``````public class ProceduralMesh : MonoBehaviour {

Mesh mesh;

Vector3[] vertices;
int[] triangles;

void Awake () {
mesh = GetComponent<MeshFilter>().mesh;
}

// Use this for initialization
void Start () {
MakeMeshData();
CreateMesh();

for (int i = 0; i < vertices.Length; i++)
{
vertices*.y = 1;*
``````
• `````` }*
``````
• }*

• // Update is called once per frame*

• void MakeMeshData () {*

• `````` //Create array of verts*
``````
• `````` vertices = new Vector3[] {new Vector3 (0, 0, 0), new Vector3 (0, 0, 1), new Vector3 (1, 0, 0), new Vector3 (1, 0, 1)};*
``````
• `````` //Create array of ints*
``````
• `````` triangles = new int[] {0, 1, 2, 2, 1, 3};*
``````
• }*

• void CreateMesh () {*

• `````` mesh.Clear();*
``````
• `````` mesh.vertices = vertices;*
``````
• `````` mesh.triangles = triangles;*
``````
• `````` mesh.RecalculateNormals();*
``````
• }*
}
The for loop is what I was using to make it go through the list. Basically, the mesh just stayed at y = 0. It’s probably something super simple, but all help would be gratefully received:)

On the mesh object you wish to Edit, you want to call SetVertices and pass the collection of vertices.

After doing so you would need to tell the mesh to recalculate it’s normals

If you’re going to be updating the mesh a lot, you’d be able to increase/save performance by calling the MarkDynamic method on the mesh object.