using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
public float health = 50f;
public ParticleSystem explosion;
public void TakeDamage(float amount)
{
health -= amount;
if (health <= 0f)
{
EnemyDeath();
}
}
void EnemyDeath()
{
explosion.Play();
Debug.Log("exploded!");
Destroy(gameObject);
Debug.Log("Enemy Dead!");
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
,CURRENT CODE:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
public float health = 50f;
public ParticleSystem explosion;
public void TakeDamage(float amount)
{
health -= amount;
if (health <= 0f)
{
EnemyDeath();
}
}
void EnemyDeath()
{
explosion.Play();
Debug.Log("exploded!");
Destroy(gameObject);
Debug.Log("Enemy Dead!");
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}