Collider2D is not working when Is Trigger enabled even they have the right rigidbody, collider and collision matrix

I’m practicing Unity on Flappy Bird game. The issue is the bird doesn’t collide with the ScoreTrigger, which is the gap between the upper and lower pipes.

I have searched and read and tried quite a number of ways for solution but to no avail, especially the documentation and post here:

Below is the screenshot while editing the collider for the ScoreTrigger and the Bird.

Bird Edit Collider

I already have Rigibody2D and Collider2D for both Bird & ScoreTrigger. The Collider2D on ScoreTrigger is enabled for Is Trigger ☑. Below are the screenshot of Inspector them.

They are on the same layer of Default and the Tags are assigned. When the bird flies through the ScoreTrigger, it doesn’t trigger anything. Below is the code for the script attached to the bird.

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.collider.tag != "ScoreTrigger")
    {
        _audioSource.clip = _gameOverClip;
        _audioSource.Play();
        GameManager.Instance.GameOver();
    }
    else if (collision.collider.tag == "ScoreTrigger")
    {
        Debug.Log("Hit Trigger!");
        _scoreCount++;
        _scoreCountDisplayText.text = "SCORE: " + _scoreCount;
        Debug.Log(_scoreCount);
    }
}

However, the bird does collide with everything else (like pipe and ground) and evoke GameOver() method. Everything else are having Rigidbod2D & Collider2D (With Is Trigger ☐ disabled).

The layer collision matrix is enabled for all.

image

I just couldn’t get the game to log “Hit Trigger!” and thus, can’t update the _scoreCount. I have been debugging for 5 hours. :sob:

Unity-2022-3-LTS

To detect interactions with triggers, you need to use OnTriggerEnter2D, not OnCollisionEnter2D.

void OnTriggerEnter2D(Collider2D collision)
{
    
}