Player health lose whenever player collide with object

Player health lose when player touch object only if the object is active. But didn’t work somehow…

public class LaserFlickering : MonoBehaviour
{
public GameObject laser; public float delay; public float maxDelay;

void Update()
{
if (delay < maxDelay)
{
delay += Time.deltaTime;
}

 else
 {
     delay = 0;
     laser.SetActive(!laser.activeSelf);
 }

}

public void OnTriggerEnter2D(Collider2D col)
{
HealthControl.health -= 1;
}

}

hello.

First, editt the code part, using the code assembler.

Second. when using ontriggerenter, need to make some kind of filter to decide which colliders will do the action. Now, all colliders in the game are activatong the healthControl.

Go google look for that.