Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Managing list of collider inside a trigger (OnTriggerExit behaviour)

Discussion in 'Physics' started by morpheusk, Nov 2, 2019.

  1. morpheusk

    morpheusk

    Joined:
    May 18, 2014
    Posts:
    3
    Hi, I was trying to keep a list of objet inside a trigger.
    So i use OnTriggerEnter/OnTriggerExit to keep my list up to date.
    But when game object are destroyed or deactivated, OnTriggerExit is never called.
    Is this a bug ?
    If it's by design, i think this is very stange.
    For destroyed object i need to clean my list from null ref (Not very elegant)
    And deactivate object, if need to remove them by check their active state.
    But cleaning the list must be done a some point and before this point, my list can be used and not in sync.
    Deactivating and reactivating object just trigger OnTriggerEnter multiple times but never exit.

    This async behaviour between OnTriggerEnter/OnTriggerExit for inactive and destroyed object is very misleading.

    Any hint how to manage this type of list in an elegant way ?

    PS: Using 2019.3.0b9
     
  2. morpheusk

    morpheusk

    Joined:
    May 18, 2014
    Posts:
    3