Hi.
I’m trying deform mesh through move the vertex in runtime.
but ,There is a gap in the generated mesh.
Could you tell me what is wrong?
Thank you.
Here is my script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
Mesh mesh;
Vector3[] initeVertices;
Vector3[] vertices;
Vector3[] normals;
int[] initTri;
public int frameCount = 0;
void Start()
{
mesh = GetComponent<MeshFilter>().mesh;
initTri = mesh.triangles;
initeVertices = mesh.vertices;
vertices = mesh.vertices;
normals = mesh.normals;
}
int count = 0;
void Update()
{
count++;
if (count == frameCount)
{
var vtx = new Vector3[vertices.Length];
for (var i = 0; i < vertices.Length; i++)
{
vtx[i] = initeVertices[i] + mesh.normals[i] * Random.value * 0.001f;
}
mesh.vertices = vtx;
mesh.RecalculateTangents();
mesh.RecalculateNormals();
mesh.RecalculateBounds();
count = 0;
}
}
}
