public class EnemyScript : MonoBehaviour
{
- [SerializeField]
- int enemyHealth;
-
- // Start is called before the first frame update
- void Start()
- {
-
- }
+ public int enemyHealth;
+ public int enemyDamage;
// Update is called once per frame
void Update()
{
- if(enemyHealth == 0)
+ if (enemyHealth <= 0)
{
- gameObject.SetActive(false);
+ Destroy(gameObject);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
- if(collision.gameObject.CompareTag("Bullet"))
+ if (collision.gameObject.CompareTag("Bullet"))
{
enemyHealth--;
Destroy(collision.gameObject);