Hello,
i tryed to make me familary with procedural mesh generation.
After modifing the “CrumpleMesh” example from the Unity-Page, i got the following problem:
I just wanted to move every plane-vertice for testing purpose 2 up. But the result ended up to be that the mesh is in place where it was at the beginning and a “clone” of the plane spawned two above the original.
In the “CrumpleMesh”-example the origin-mesh is modified.
Here is the code:
private Vector3[] baseVertices;
void Start()
{
renderer.material.color = Color.white;
Mesh mesh = GetComponent<MeshFilter>().mesh;
baseVertices = mesh.vertices;
Vector3[] vertices = new Vector3[baseVertices.Length];
for (int y = 0; y < mesh.vertices.Length; y++)
{
Vector3 vertex = baseVertices[y];
vertex.y += 2;
vertices[y] = vertex;
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
}
The Code is attached to the plane.
What is wrong? I hope the problem is understandable.
Thank you for your help.