So when I shoot my bullets and an enemy it sometimes causes 2, or even 3 collisions to happen before the bullet gets destroyed.
code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHealth : MonoBehaviour {
public float hp;
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Bullet")
{
Destroy(col.gameObject);
hp -= 1f;
}
if (hp < 0.1f)
{
Destroy(gameObject);
}
}
}
and also if there is a better way to tell if the enemy is dead it would be useful. Thanks in advance