Body Collision Mask

Options
Hi,

I've seen that is TSCollider.CreateBody() the body instance is flagged with:

body.CollidesWith = Physics2D.Category.All;

Why does this field is not used? I suppose that using a mask like that could be more efficient that using LayerCollisionMatrix.

Thanks,

Devis

Comments

  • JeffersonHenrique
    Options
    Hi @Devis,

    You made a good observation, but internally we use collision matrix in the same way as this field, so we get the same performance and we didn't change much how you used to do with Unity. Thanks for this, any suspicion you have we are glad to hear it.
  • Devis
    Options
    Ok, the drawback maybe is that in order to check a body's layer you must find it into the object map. And this search is done for each pair of objects, in each callback...
  • JeffersonHenrique
    Options
    Yes, you are right @Devis, but we optimized this operation to get a fast access. Of course we can reimplement that later to get a bit more performance as you suggested. Thanks for the report.
  • Devis
    Options
    Thanks @JeffersonHenrique for your support!