# GetComponent\<MeshFilter\> problem

**URL:** <https://discussions.unity.com/t/getcomponent-meshfilter-problem/38146>\
**Category:** Questions & Answers\
**Created:** [March 13, 2012, 6:01am UTC](https://discussions.unity.com/t/getcomponent-meshfilter-problem/38146 "2012-03-13T06:01:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/system/32/97283_2.png) [@system](https://discussions.unity.com/u/system)\
**Post date:** [March 13, 2012, 6:01am UTC](https://discussions.unity.com/t/getcomponent-meshfilter-problem/38146/1 "2012-03-13T06:01:16Z")

</div>

Hey everyone. I’m trying to make a damage system do an object. I have 3 render meshes and 3 colliders meshes(Both MeshFilter and MeshCollider Components are in my object), but when I call them with this script:

```
switch(curMesh) {
		
	case possibleMeshes.undamaged:
		
		Mesh newMesh = damagedMeshes[1];
		GetComponent<MeshFilter>().mesh = newMesh;
		Mesh newCollider = damagedMeshesColliders[1];
		GetComponent<MeshCollider>().sharedMesh = newCollider;
		
		break;

```

}

Gives me an error in GetComponent.mesh = newMesh. The error is : ‘Object reference not set to an instance of an object’. I don’t know what to do anymore. Somebody can help me?

Thanks from now!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/system/32/97283_2.png) [@system](https://discussions.unity.com/u/system)\
**Post date:** [March 13, 2012, 7:01am UTC](https://discussions.unity.com/t/getcomponent-meshfilter-problem/38146/2 "2012-03-13T07:01:46Z")

</div>

Problem solved!
