Hello everyone,
ok so after messing with my game for awhile I decided to redo the way my player receives damage. The only problem now is that when the enemies hit my player he only gets damaged once and not continuously. If possible can someone help me to make it so that when my player is hit he takes damage continuously?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerHealth : MonoBehaviour {
public int health;
public Slider healthbar;
public EnemyDamageHandler enemy;
void Start(){
}
void Update(){
healthbar.value = health;
}
void OnTriggerEnter2D(){
health -= enemy.zombieDamage;
Debug.Log ("Player Hit!");
if(health <= 0){
Die();
}
}
void Die(){
Destroy(gameObject);
}
}
Thanks in advance