I have the health bar appearing on my screen, but I am not sure how to link the Health script of the health bar to my player script and my player’s health script. Simply, I want to make it so when my player gets shot my health bar will lose a heart. The health script of the player’s is also linked to the enemy.
My health bar is made with a GUITexture heart
I used this video for the health bar and now I need to figure out how to incorporate the health bar script with my health script and and player script
I get the impression that I need to include some lines of code from my health bar script or link it/reference it some how in my player script
my code is in the link in the same question that I asked on stack overflow…
I can not go over all the scripts there, but as a simple way;
int = numberOfLives;
public List<GUITexture> hearts; // or array, does not matter, you should assign GUITexture objects from the inspector, 5 of them if you have a max of 5 lives
void HealthBar(){
for(int i = 1; i <= hearts.Count; i++){
if(i <= numberOfLives){
hearts*.gameObject.SetActive(true);*