Object acting as collider not trigger

Hi!

New to Unity and C#, so apologies if this is obvious, but I have done a lot of searching and haven’t found a solution to this yet…

I have a 2D player object (set up with a box collider 2D and as a rigidbody2D). I want to interact with other objects in the scene to provide clues. First clue object - set up with box collider 2D with ‘is trigger’ checked. Player interacted as required.

Second clue object - identical set up and script (different sprite and tag). Player is interacting as though the object is a standard box collider without ‘is trigger’ checked.

I have:

  1. Double checked ‘is trigger’ is checked.
  2. Reset the box collider and tried again
  3. Changed the tag to match that of the first clue object so the event should be triggered by the script associated with the first object tag (to check I haven’t accidentally mistyped etc)
  4. Removed all surrounding boxcolliders (walls etc) to check player isn’t being blocked

Player is still stopping when she collides with the object rather than triggering the scripted event. (Which still triggers fine for the first game object).

I’m pretty sure its going to prove to be something innocuous and simple but I’m fresh out of ideas - any help would be appreciated! I don’t think it’s the script (as it works fine with the first game object) but I’ve copied the relevant lines below just in case.

Thanks!

void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag ("FullBed"))
        {
            other.gameObject.SetActive(false);
            bedImage.SetActive(true);
        }

        else if (other.gameObject.CompareTag ("ExitM1toM2"))
        {
            other.gameObject.SetActive(false);
            aftExitImage.SetActive(true);
        }
    }
}

As suspected - it was straightforward (although took a couple more hours of investigating to solve)!

Turns out I was having the same problem with my other object as well, but this was masked due to the relative directions of approach. The problem stemmed from the script I have written for my player movement. As the player is kinematic (the game view is top level rather than side on so dynamic had her bouncing around like a balloon) I’d written some code that caused the player to send out a Raycast and only move if nothing was hit, but forgotten to add my blocking layers to the code so the player was stopping before she could enter the collider of the trigger objects.

Simples! I don’t appear to be able to remove the question (guessing that’s cos I’m a newbie) so hopefully my answer may save someone else half a day of pain.

Had same issue (trigger “acting” like collider) in 3D. It was because my player controller used a trigger at the feet to determine if it was grounded. The issue was that if the foot trigger ran into another trigger that was attached to an item in my ground layermask and assumed it was grounded. Added this line so it could distinguish triggers from colliders when doing ground checks . . .

private void OnTriggerEnter(Collider other)
    {
        if (other.isTrigger) return; //<--- new line of code to avoid considering collisions with triggers

        //otherwise consider it a collision and find out if it was with the ground
     
    }