I have a problem with collision in my project. I am using a weird flappy bird model I made. It has a beak, 2 eyes, and 2 black pupils. All of those are marked with the same tag in my project. I am also using a death counter and whenever the front of the model hits something that’ll kill you, The death counter goes up by 3-5 times. So I want to check that if there is more than one of the same tag colliding with a dangerous object, It will add only one to the death counter.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class FailLevel : MonoBehaviour
{
public string strtag;
private void OnCollisionEnter(Collision collision)
{
if (collision.collider.tag == strtag)
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
DeathCounter.NumOfDeaths += 1;
}
}