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!