- Home /
Question by
Ercova · Oct 06, 2021 at 03:13 PM ·
meshmeshfiltermesh verticesmesh manipulationmesh-deformation
How to manipulate(flatten) the Mesh of an object
Hello again. I try to make an ironing system. I have an iron and uneven objects and when this iron on the object i want the hit point of the objects be flatten. this is the unity's own code for manipulating mesh. Can i use it for that purpose? if not can u give me a hand? if so how can add iron impact with ray onto it? Any help will be appreciated. Thanks
using UnityEngine;
public class Example : MonoBehaviour
{
void Update()
{
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
Vector3[] normals = mesh.normals;
for (var i = 0; i < vertices.Length; i++)
{
vertices[i] += normals[i] * Mathf.Sin(Time.time);
}
mesh.vertices = vertices;
}
}
Comment