I’m looking to take a sphere mesh and randomize the height as well as smooth the vertex just like i’m able to do in blender (only I want to do this in C# within unity)
In blender when I have a sphere selected and click randomize, I am able to see different height and depth added to the sphere and there are no holes or problems.
My code:
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
float [][] verticesArray;// = new float [vertices.Length][3];
verticesArray = new float [vertices.Length][];
int vertexCount = mesh.vertexCount;
int j = 0;
while (j < vertices.Length)
{
verticesArray[j] = new float [3];
Vector3 vUp = Vector3.MoveTowards(vertices[j],Vector3.zero, .05f);
vertices[j] = vUp * Random.Range(0.9f, 1.1f);
j++;
}
I’m trying to have the vertices move upwards (opposite of the direction towards the center) with some variation - but the sphere has a lot of gaps and is not smooth.
Please help !
Here is what is happening in Unity…
Here is what I’m trying to do in unity (the picture is while using blender)