'unity isn't registering the collsion between my player and the obstacles

I have tried for some time to fix the problem I'm having, I've looked at tons of different websites and I can't find what is wrong with my script. The player (Where the script is located) has a box collider 2d and a rigidbody 2d while the spike (collider) only has a box collider 2d. I've tried using normal collisions, triggers and everything in between, i've also confirmed that the spelling on the tags are right but I just can't find what is wrong. Here is my code for the collision script:


public class Collision : MonoBehaviour
{
    
    void OnCollisionEnter2d(Collision2D collision)
    {
        if (collision.gameObject.tag == "obstacles")
        {

            Debug.Log("Hello");
            GetComponent<GameManager>().endGame();
        }

    }

}


Solution 1:[1]

Languages can be case sensitive void OnCollisionEnter2D(Collision2D collision). 2d - 2D

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Blackmoon