- Home /
OnTriggerExit2D not triggering when disabling collider
Any workarounds for this? I'm thinking of moving the colider far far away when disabling it hoping that will still trigger this.
Just mentioning that otherwise this works properly, triggerring on enter/exit.
If I understood you right you disable collider with trigger on it and want trigger to trigger without a trigger? oO That's not gonna work.
I was just talking about the exit callback. I found it surprising that trigger exit didn't happen as the collision is no longer happening. From an implementation perspective, I would expect the physics system to keep track of which collisions are happening and next physics frame, to check which are still happening or not (in order to call the stay/exit callbacks on them).
Answer by DoTA_KAMIKADzE · Apr 19, 2015 at 04:53 PM
Yes it doesn't call OnTriggerExit2D if object gets destroyed or its collider went off inside collider, as instead depending on your situation you might want to use OnTriggerStay2D which does check continuously or you might want to use OnDestroy for your logic on the object itself if it gets destroyed. Or you might even track it yourself using Enter/Exit, then again that depends on what you're trying to achieve.
Yeah I found a workaround that's only applicable to my project. What was even more surprising about this was that googling this not many people ran into it...
Your answer