[Unity] Something similar to OnTriggerExit

Topics: Developer Forum
Sep 16, 2013 at 2:28 PM
Edited Sep 16, 2013 at 2:51 PM

I'm using the Farseer plugin for Unity and I need to have something like Unity's OnTriggerExit.

I have a body A that is a trigger (always return false in OnCollisionEvent) and a body B that is a regular collider (always return true in OnCollisionEvent). I would like to know when those body are not colliding anymore.

I'm guessing that, since when those two bodies are colliding one of them (the trigger) is always ignoring the collision, the collision is never "registered" by Farseer and therefore OnSeperation is never called on either of them.

I could register every collision in OnCollisionEvent and check every frame if one of those collisions has been resolved but that seems complicated for something so simple.

Thanks for your help.

Precision :
  • Those two bodies are not near each other at frame 0.
  • I'm not using categories collision filtering anywhere.
  • I'm a beginning user of Farseer but not of Unity.
Sep 16, 2013 at 8:48 PM

I haven't used the unity plugin so not sure if these options are available but in regular FPE you do the following:

Use Body.IsSensor = true to keep the collision detection but disable the body's collision response rather than returning false in the OnCollision event

And the Body.OnSeperation delegate should fire when bodies stop colliding.