Search Unity

Unity, OnCollisionEnter before RigidBody2D takes effect (so I can ignore collision).

Discussion in 'Physics' started by DearUnityPleaseAddSerializableDictionaries, Aug 22, 2021.

  1. DearUnityPleaseAddSerializableDictionaries

    DearUnityPleaseAddSerializableDictionaries

    Joined:
    Sep 12, 2014
    Posts:
    135
    Without using the Physics Collision Layer Matrix, is there a way to Ignore collision using `Physics.IgnoreCollision` before the RigidBody takes effect (i.e. before any collision / physics happens)?

    I want to do it at OnCollisionEnter for efficiency, otherwise the complexity can be very large if I do it at Awake() `O(n^2)` if I make every of these objects loop through every object in the scene/array.

    Is there a way to Ignore collision efficiently (i.e. only when it needs to).

    The reason I don't use the Layer Collision Matrix is that I am using it for something else and also I would need 50+ layers (very complex to explain).

    Alternatively, is it possible to make a "Physics Collision TAG matrix"?

    Is it possible or not? Thank you
     
    Last edited: Aug 22, 2021