- Home /
Question by
Dan the Man · Jun 05, 2011 at 05:52 PM ·
meshvertices
Get certain vertices?
I can get a mesh's vertices with mesh.vertices
...
But how can i access just certain vertices? like the top vertices.
Comment
what are top vertices?
mesh.vertices contains all vertices. you can access them all there. but for filtering out important ones i guess you should somehow mark them.
Best Answer
Answer by Peter G · Jun 05, 2011 at 07:35 PM
You really just need an algorithm for grabbing whatever verts you want. Here's an example:
var verts : Vector3[] = mesh.vertices;
//grab all the mesh's vertices
for (var i : int = 0; i < verts.Length; i++) {
if(verts[i].y > someValue) {
//mesh vertices are in local space.
//edit the vertex info. You could get a simultaneous array of vertex colors or uvs for example
verts[i] += Vector3.up * Mathf.Sin(Time.time);
}
}
mesh.vertices = verts;
Wow! that's ingenious! thanks alot!
one question: the verts.y would would that be in world space or local?
vertices returns a collection of points in local space so it would be local. You could turn them into world space if you wanted to, but by default they are in local space.
Your answer
![](https://koobas.hobune.stream/wayback/20220612095633im_/https://answers.unity.com/themes/thub/images/avi.jpg)