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

GameObjects won't collide

Discussion in '2D' started by Layneee, May 19, 2017.

  1. Layneee

    Layneee

    Joined:
    May 19, 2017
    Posts:
    4
    I'm new to Unity so it's probably a really easy thing, but i can't understand why it isn't working.
    I basically have two Gameobjects, one has a Rigidbody 2d and a Box collider 2D, while the other has only a Box Collider 2D.
    The two objects collide when i run the game, but Unity won't recognize it.

    This is the code i used to see if the two objects collide, and the console is always empty.
    Is there a problem with the code or with something else?
    I already tried a few solutions but i can't get over this problem:
    - the two objects are on the same layer and can collide.
    - both objects have the IsTrigger option checked.
    - the object with the Rigidbody doesn't have the 'isKinematic' option checked.
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    You want:
    Code (csharp):
    1. void OnTriggerEnter2D(Collider2D collider) {
    not
    Code (csharp):
    1. void onTriggerEnter2D(Collider2D collider) {
    Capitalization is important.
     
  3. Layneee

    Layneee

    Joined:
    May 19, 2017
    Posts:
    4
    Thank you man!