Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question What kind of tigger would be triggered with different collider types?

Discussion in 'Physics' started by Bagazi, Dec 11, 2022.

  1. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    610
    Hypothesisly, I got two 2d colliders named A and B,A is not a trigger but B is. So when the two collides which unity message will be triggered on A? OnTriggerEnter2D or OnCollisionEnter2D?

    For my test, I dont get anyone of them... The layer filter setting is OK. It is just a litte different that I used

    Code (CSharp):
    1.               if (damageEntities[args[1]].BoxCol2D != null)
    2.                     {
    3.                         damageEntities[args[1]].BoxCol2D.enabled = true;
    4.                     }
    5.                     if (damageEntities[args[1]].CircleCol2D != null)
    6.                     {
    7.                         damageEntities[args[1]].CircleCol2D.enabled = true;
    8.                     }
    for active the B collider which was inactive from beginning.


    PS: The A and B are overlapping in 2d space.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,105
    If either is a trigger, only trigger callbacks happen but that's easier to test yourself than ask TBH. If you don't get this then it'll be something odd in your scripts/projects so you should experiment in an empty project before you address other issues in your project.

    Also, I have no idea what your code above is trying to show. Are you indicating that these things are inactive? They won't collide if they're inactive as they don't exist.