I have been getting a nagging error on pickup objects when they get destroyed.
I have attached a particle emitter to the object which gets detached before the object is destroyed but I'm not sure that this is influencing the problem since I turn off this section and still get the error.
I detach this of course, because I want to have something happen to show you picked something up, and it has to linger after the object is destroyed otherwise it will be destroyed immediately.
Here is the error:
MissingReferenceException: The object of type 'MeshCollider' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.
Has anyone seen this or can you point me in the right direction so I can clean this up?
I think you don't need the "blah" variable at first place. There's probably some script either on the transforms that you detached or on other object that is trying to use your destroyed gameObject, more specifically a mesh collider. I would try to replace the mesh collider with a box collider or sphere collider since your object is a collectable "pickup" I think? Box or sphere colliders takes much less cpu when using to movable objects.
answered Aug 10 '10 at 07:15 AM
okay I tried these suggestions with no luck but it got me deeper into debugging my script.
It turns out that my collision check was doing a check for what if I hit different objects, what happens then however it went from one if statement to another, not followed by an else if.
I added else if to my collision checks, and this cleaned up my logic.
answered Aug 11 '10 at 05:30 AM