[solved] The health bar of multiple enemies combined into a single health bar

I’m making a game, I want all the enemies’ health to appear in a single common health bar, but I couldn’t figure out how to do it. I tried, but when there was more than one of the same enemy, it only added the health of one of them.

visual example:
idle - Kopya

When there’s a change to any of the enemy’s health, you’ll have to run a repeat for each enemy and sum up their health.

Alternatively, you sum up their health once and keep that in a variable, and then take off any damage that they receive.

I tried collecting them in a variable, but when there are two of the same enemy, it only counts one.

code:

game:

Edit: I tried what you said (but I think I didn’t fully understand it). Excuse me for my bad English. Can you explain it in a little more detail?

Put all your enemies into an object group (for example called EnemyGroup). Then loop over each EnemyGroup in a “Repeat for each object” event, adding the health value:

1 Like

I tried the example you showed and it worked, thank you very much for your help.