Collider2d Not Working- Should Be Simple

I have a collider 2d on two gameobjects, both a enemy and a player. When the enemy touches the player I want the players health to decrease, which is in another script “progress”. Both the player and the enemy have rigid bodies on them as well. Trigger is not selected on either.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class collision : MonoBehaviour {

public progress Progress;
void Start(){
GameObject.FindGameObjectWithTag(“HealthBar”).GetComponent();

}

void OnCollisionEnter2d(Collision2D coll){
if (coll.gameObject.tag == “box”) {

Progress.curHealth -= 1;

}
}
}

OnCollisionEnter2d should be OnCollisionEnter2D

1 Like