I imported an Ico Sphere from Blender and want to change the position of some of its vertices. Here’s what I wrote:
[SerializeField]private float m_DeformationMultiplier;
[SerializeField]private float m_HitRange;
[SerializeField]private Vector3[] m_Vertices;
private Mesh m_Mesh;
void Start()
{
m_Mesh = GetComponent<MeshFilter>().mesh;
}
public void OnHit(RaycastHit _hit)
{
Debug.Log("Hit Recieved");
m_Vertices = m_Mesh.vertices;
for(int i = 0; i < m_Vertices.Length; i++)
{
if(Vector3.Distance(m_Vertices*, _hit.transform.position) < m_HitRange)*
-
{*
m_Vertices = m_DeformationMultiplier;
_ }_
_ }_
m_Mesh.vertices = m_Vertices;
_ }*_
The m_Vertices-array is working. I get all the vertices’ positions, but even if I change some values in the inspector they just won’t change on the screen and as soon as OnHit is called they change back to their former value.
Please help me figure this out.