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();
}
}
}
CodePudding user response:
Languages can be case sensitive void OnCollisionEnter2D(Collision2D collision). 2d - 2D