- Home /
Collider sharedmesh crash
Hi, I'm working into a unity's project, and there is a null pointer occuring inside the collider's sharedmesh setter:
Invalid parameter because it was infinity or nan. UnityEngine.MeshCollider:set_sharedMesh(Mesh) UnityEngine.MeshCollider:set_sharedMesh(Mesh) ...
at (wrapper managed-to-native) UnityEngine.MeshCollider.set_sharedMesh (UnityEngine.Mesh) <0x00004> at (wrapper managed-to-native) UnityEngine.MeshCollider.set_sharedMesh ... State.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff> Receiving unhandled NULL exception Trying to recover from null exception ]
and after this, the game freezes. i have checked the mesh, and its valid, have vertexes and indexes ( triangles ), and the collider is not null. Somebody know what can be the problem? it can be a unity bug?
Thanks.
Answer by dhill · May 27, 2010 at 06:41 PM
I think this is a bug. I was having a terrible time tracking down a similar (occasional) error when setting a MeshCollider, though mine was an "Object reference not set to an instance of an object". It turned out that previously in the same function I had done a try/catch. The catch had handled an exception caused by a null reference. Apparently something about the error condition was not cleared and Unity's code for setting the sharedMesh of the MeshCollider responded to it.
I suggest you check your code to see if you are trapping an invalid parameter exception. Perhaps you can check the parameters manually and avoid precipitating this bug, if bug it is. That is what worked for me. If there is a way to clear an error condition, I'd love to hear of it.
I have investigated a little more, and discovered that the freezes occur always while running the instantiate method, but not always with the same prefab. I removed all the scripts of one of these prefabs, and sometimes it's still freezing while instancing these prefabs. I have done other tests like an empty scene instantiating this prefab and the problem didn't occur. Any ideas about this problem? What could cause this or any warnings? i have checked the thread where i'am calling the instantiate, and it's always in the unity's thread.