- Home /

# Manipulating vertices through colliders

Hey, I'm experimenting with Fog of War and trying a different approach than the usual raycast/transparency. I have a plane's vertices stored in an Vector3 array. I also have a sphere collider that checks if there are any vertices in it and if there are, submerge them by putting their Y on -1.

Now the mesh reacts to it, but not how its suppose to. Currently only the center few vertices seem to react on my sphere collider. Anyone any idea where I went wrong? This is my current script:

```
for(int i = 0; i < vertices.Length;i++){
vertices[i] = OriginalPositions[i];
if(ManipulatingObject.bounds.Contains(OriginalPositions[i])){
vertices[i].x = -1;
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
}
```

Mesh vertices are in local coordinates. Is the ManipulatingObject.bounds also in local coordinates? Collider.bounds will be world coordinates.

Ah yes, this helped me a lot! Posted an answer based on your insight.

**Answer** by Danzou
·
Jan 14, 2014 at 05:30 PM

Apparently, vertices are in local space, so it's necessary to convert them to world space using transform.TransformPoint. Also, apparently my axes were off. Working script:

```
for(int i = 0; i < vertices.Length;i++){
vertex = OriginalPositions[i];
Vector3 temp = vertex;
temp = transform.TransformPoint(vertex);
if(ManipulatingObject.bounds.Contains(temp)){
//Debug.Log (temp);
vertex.z = -1;
}
vertices[i] = vertex;
mesh.vertices = vertices;
}
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.