In my example I have a character with 2 colliders on it. Capsule collider and box collider. Also, I have a heart gameobject with its own script as shown below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HeartCollectable : MonoBehaviour
{
private void OnTriggerEnter2D(Collider2D collision)
{
if (Player.playerHealth < Player.numberOfPlayerHeart)
{
Player.playerHealth += 1;
Destroy(gameObject);
}
}
}
My problem is, when I jump and land on this game object. My capsule and box collider trigger simultaneously. That way player gain 2 health instead of 1. How can I trigger only one of them ?



