can i get help with triggers in 2d

here is my script:

using UnityEngine;

public class threewayspawner : MonoBehaviour
{

private void OnTriggerEnter2D(Collider2D other) {
    if (other.gameObject.CompareTag("trigger threeway 1")){
        Debug.Log("player walked past!");
    }

}
};

i cant for the life of me get the triggers to even register and console log anything
i am a complete beginner and have about 6hours of unity experience, i am using the is trigger on the colliders

To make physics methods like OnTriggerXXX, OnCollisionXXX, etc. work, both objects need to have colliders, and at least one of them needs to have a Rigidbody. If your objects only have colliders, these physics callbacks will not be invoked.

one of my objects have a rigid body

my player:

my trigger:
9754786--1396507--image_2024-04-07_104841192.png

You’ve hidden the most important part in that screenshot - is “IsTrigger” enabled in the trigger collider?

If I were you I’d also remove the additional check in your method to rule out typos in your tag

private void OnTriggerEnter2D(Collider2D other) {
  
        Debug.Log("trigger", other.transform);
  
}

You can add it back in after you get things working.

And make sure that both objects are on layers that are set to collider in the project settings

when you talk about the layers do you mean that it needs to be on the same layer? And the is trigger is selected. sadly it still didnt work when i put both of them on the same layer, and updated the code to the one posted above

The layers need to be set to interact/collide with each other in the Layer Collision Matrix
Edit > Project Settings > Physics2D

Worth checking. Although if you’ve never changed the layer matrix, it’s likely that this isn’t the problem.

(You’ve definitely attached your script to the object?)

i made the green trigger work, since it has the script. but i want the green box to read when i touch the yellow one.

Now that it’s working, you can reintroduce your Tag check. But note that the tag of the yellow object is “Finish” not “trigger threeway 1”

private void OnTriggerEnter2D(Collider2D other) {
    if (other.gameObject.CompareTag("Finish")){
        Debug.Log("FINISH!", other.transform);
    }
}

(Of course you could attached the script to the Finish object instead, and check against the tag of the green object)

i made it work, although i didnt use the code you submitted, thx for the help anyways