enemy bar link together
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemyhealing : MonoBehaviour
{
bulletmovement howgetdamge;
public HealthBar healthbar;
enemy thisenemy;
void Start()
{
thisenemy = FindObjectOfType<enemy>();
healthbar.SetUp(thisenemy.EnemyHealth);
}
// Update is called once per frame
void Update()
{
}
}
this is the bar
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HealthBar : MonoBehaviour
{
private healthSystem HealthSystem;
public void SetUp (healthSystem HealthSystem)
{
this.HealthSystem = HealthSystem;
}
private void Update()
{
transform.Find("Bar").localScale = new Vector3(HealthSystem.GetHealthPercent()*10, 1);
}
}
how I spread the enemy bars every time I do damage to one of tham all the health bar of all the enemy go down