- Home /
Update List Item
Hi, I have a project where I want to reposition vertices depending on the distance to a ray point. The problem is, that I do not know how to update an item within the vertices list. This is the code I have right now:
Mesh pMesh = hit.collider.GetComponent<Mesh>(); //Get Mesh
List<Vector3> allVertices = new List<Vector3>(); //Create List
pMesh.GetVertices(allVertices); //Get Vertices in List
List<Vector3> pVertices = new List<Vector3>(); //Create List
foreach(Vector3 vertice in allVertices){//Go through all Vertices
float dist = Vector3.Distance(hit.point, vertice);//Get Distance
if(dist < size){//If Distance is smaller than Size
Vector3 tempVertice = vertice + transform.forward * (1-dist);//Get New Position
}
How do I update the Vector in the allVertices List?
Comment
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How can I assign an Array of Vector3 while seeing and editing the values in the Scene? 0 Answers
Looping through multiple lists 0 Answers
How to combine Vector3 arrays? 3 Answers
auto change script in published build 0 Answers