Hi! I’ve been working on making it so that an enemy takes damage when
public GameObject hitEffect;
public int damage;
void OnCollisionEnter2D(Collision2D collision)
{
GameObject effect = Instantiate(hitEffect, transform.position, Quaternion.identity);
Destroy(effect, 3f);
Destroy(gameObject);
}
void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Enemy")
{
collision.gameObject.GetComponent<EnemyHealth>().currentHealth -= damage;
Destroy(gameObject);
}
}
}
hit by a bullet, however, I can’t get the bullet to do any damage upon collision. Any help is much appreciated!!!