R
ruwcom
Guest
So I made a health bar object for the enemies of my project, when the enemy gets hit it creates a health bar in the room and it shows how their health points decrease while receiving damage, checking that info from the create event of the enemy.
The problem is that, when I have multiple enemies on the view, the bar only keeps track of one random enemy, so when I hit other enemy the bar creates itself but it's always full, because the enemy that it's getting the information from isn't receiving any damage. I need to kill the enemy that works with the bar so it can track the HP of another enemy, but then the problem is the same.
My question is, is there a way to create a bar that keeps track of the HP of the enemy that created it? also my intention is to have only one enemy health bar showing at the time.
The code to create the bar
And the code of the bar itself, if that helps
The problem is that, when I have multiple enemies on the view, the bar only keeps track of one random enemy, so when I hit other enemy the bar creates itself but it's always full, because the enemy that it's getting the information from isn't receiving any damage. I need to kill the enemy that works with the bar so it can track the HP of another enemy, but then the problem is the same.
My question is, is there a way to create a bar that keeps track of the HP of the enemy that created it? also my intention is to have only one enemy health bar showing at the time.
The code to create the bar
Code:
if (place_meeting(x,y,obj_hitbox)) && (damage = false)
{
instance_create(x,y,obj_enbar);
}
Code:
///the background of the bar
draw_sprite_ext(spr_enemylifered, 0, 129, 52, 1, 1, image_angle, image_blend, 1);
///the green bar that gets smaller with the damage
draw_sprite_ext(spr_enemylifegreen, 0, 130, 53, (obj_enemy.hp / obj_enemy.maxhp),1, image_angle, image_blend, 1);