Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Detected bug with triggers collisions 2D

Discussion in 'Physics' started by DarkSchneider, Dec 2, 2015.

  1. DarkSchneider

    DarkSchneider

    Joined:
    May 25, 2015
    Posts:
    12
    For triggers to work, at least one object must have a rigidbody2D. But I have detected that if the object with rigidbody2D is not moving, the triggers don't work.

    A temporal solution for this is to add a rigidbody2D to all elements with triggers, so triggers always work. Even if all rigidbody2D are kinematic (the case I detected the bug). But I think this should be fixed to avoid confusion.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,563
    Triggers don't have rules on what can trigger them; rigid-body types define this.

    A collider is defined by the body it is attached to. If the Rigidbody2D is kinematic then the collider is. If the Rigidbody2D is non-kinematic (dynamic) then the collider is. If there's no Rigidbody2D then the collider is static (meaning it should not be moved).

    Static itself won't contact anything. Dynamic can contact it however.
    Dynamic will contact static, kinematic & dynamic.
    Kinematic will contact dynamic.

    Whether it's a trigger or not is irrelevant. Whether the body type can contact is all you need to know.

    If you have static colliders marked set as triggers then (using the list above), only dynamic colliders can come into contact with it no matter if it's a trigger or not.

    Manual: Colliders Overview
     
  3. DarkSchneider

    DarkSchneider

    Joined:
    May 25, 2015
    Posts:
    12
    OK I understand. In that case it should be specified in documentation. As said it can be confusing. Thanks.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,563
    I gave you a link that describes which bodies collide with which and shows you triggers/non-triggers separately. Was there something else you wanted documented?