im pretty new to using unity and i really want to use colliders. problem is they dont work. ive tried every single tutorial on youtube and documentation online and nothing works. i have a rigidbody2d boxcollider set it to is trigger and no success. i tried a basic ontriggerevent method like in those tutorials and nothing happens in the console even with Debug.Log. please help, im legitimately pissed off over trying to figure it out. im using unity 2017.4.32f for monodevelop btw

  • create a new 3D scene

  • create two cubes. call one “TriggerCube” and the other “Player”

  • select the Player cube and tag is as “Player”

  • create a new script and attach it to the TriggerCube. Remove Start() and Update() methods.

  • mark the TriggerCubes collider as Trigger
    _
    Paste this into the script where Update() used to be. Play the scene and in the hierarchy select the player cube and move it through the trigger cube and you should see the trigger messages.

    void OnTriggerEnter(Collider other)
    {
    if (other.tag == “Player”)
    {
    Debug.Log(“Player entered trigger area”);
    }
    }

    void OnTriggerExit(Collider other)
    {
    if (other.tag == “Player”)
    {
    Debug.Log(“Player left trigger area”);
    }
    }

This is pretty much how it works on 2D… well im 99% sure. Never worked with 2D stuff. But it should be the same concepts. The trigger code needs you to tell it “what” collided with it and the easiest way is to use tags. Just get the tag of the gameobject that enters/leaves a trigger collider.

_
Also, as a side note, on the very small chance this is causing your issue - if you happen to have different objects on different layers (all triggers on one layer and the player on another layer) you need to edit the physics settings so those layers will interact with each other.