Is the OnTriggerEnter function supposed to be called when the collider that it is interacting with is disabled? Right now I have code that is being called when a mesh collider tagged as “Weapon” enters the trigger but the mesh collider is disabled. Is this a Unity bug? Is there a clean way around this other than disabling the gameobject associated with the mesh collider?
I’ve just tested to be sure… if turned off, the mesh collider will not activate the trigger… you must have another collider (or a character controller) attached to the object
OK, actually I take that back… I was using the mesh collider on the trigger, but the other way around, yep, you’re right, it still works! seems like a bug to me…
No other reason that should happen with a disabled component… I say submit it!
as for a clean way around it… you may want to remove/re-add the component rather than disabling it, that will be easy…:
and to add it back:
Or, maybe on the trigger you can do a check like:
that should do it to…
(The second way is probably cleaner, since adding a mesh collider at runtime is more costly… And I just confirmed it DOES work)