Search Unity

Non-physical collider

Discussion in 'Physics for ECS' started by cultureulterior, Feb 24, 2020.

  1. cultureulterior

    cultureulterior

    Joined:
    Mar 15, 2015
    Posts:
    68
    I'm looking for the ability to have a collider that can be used for OverlapAABB, but that doesn't participate in collision physics at all (and so doesn't incur the cost), but is still usable in jobs, and is still locatable with an AABB overlap.

    This is for moving non-physical enemies, e.g ghosts.

    From what I'm seeing on the forum (the dots physics documentation is minuscule), it's impossible- things have to participate in the simulation (be added as physicscolliders) in some way? Should I be making these in another, empty, physicsworld?
     
  2. Rory_Havok

    Rory_Havok

    Joined:
    Jun 25, 2018
    Posts:
    70
    If you give your (static) collider a collision filter such that it only collides with your query and nothing else, then it will not be reported as a collision pair during simulation so will not participate in it. The simulation's broadphase query will early out quickly in that scenario, so the impact of having them in the same broadphase as everything else should be minimal.

    (Maybe if you have very many of those objects it might make some sense to move them to their own world but then you have to manage the worlds yourself and consider how you reconcile queries involving multiple worlds - so that would be a last resort if you find that it having them in one world really causes a performance bottleneck.)
     
    cultureulterior and florianhanke like this.
  3. cultureulterior

    cultureulterior

    Joined:
    Mar 15, 2015
    Posts:
    68
    Thank you, that's really helpful! You're saying (static), though- I'm assuming would this work with non-static as well? I'll try it anyway
     
  4. Rory_Havok

    Rory_Havok

    Joined:
    Jun 25, 2018
    Posts:
    70
    Yes that is applicable to non-static bodies too, apologies.