Question by
Toppcar_Whitlock · Aug 03, 2020 at 06:26 PM ·
health-deduction
Hitpoints, what am I doing wrong here?
Work in progress, for some reason my enemy is still destroying after just one hit with the bullet
public class BulletScript : MonoBehaviour {
[SerializeField] int Hitpoints = 3;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(Collision collider)
{
if (collider.transform.tag == "enemy")
{
Hitpoints--;
if(Hitpoints<=0)
{
Destroy(collider.gameObject);
}
Destroy(collider.gameObject);
}
}
}
Comment