using UnityEngine; using System.Collections; public class EnemyHealth : MonoBehaviour { public static float health; public WeaponStats currentWeapon; void Start() { health = Random.Range(50, 500); } // Update is called once per frame void Update() { if (health <= 0) { Destroy(gameObject); } } //allow the player to only be hurt by the enemy void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Enemy") { Debug.Log("hit"); health = health - Random.Range(currentWeapon.damageMin,currentWeapon.damageMax); } } }