I am making a tower defense and i wan’t my enemies to have a hp-bar over their head. The only problem i have is that ones the enemy has gotten damaged it don’t get damaged a second time! How do i resolve this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class hpScaleDino : MonoBehaviour
{
GameObject hp;
[SerializeField]
public float x = 0.1f;
[SerializeField]
public float y = 0.1f;
[SerializeField]
public float z = 0f;
void Start()
{
hp = GameObject.Find("hp");
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Tower1")
{
hp.transform.localScale -= new Vector3(x, y, z);
print("hit");
}
}
}