Stop all my enemies health from being linked

So I’m having trouble working out how to stop linking the lives system for my enemies. I have got the animation working for the lives, as well as them dying when they reach zero lives, but now they all lose hearts.

For example, when I jump on one, every enemy will lose one heart and not just the one I jumped on. It’s probably a simple solution…

Anywho, here is a couple screenshots of the code:

In this event and it’s subevents, which instance of Health_Bar_Enemies are you referring to?

As it turns out, all of them. They have not been filtered with a condition.

You’ll need to link each Health_Bar_Enemies object with the Slime that it belongs to.


Additionally, you are storing the slime lives/health in a scene variable. This means all Slimes will have the same health. If one dies, they all die.

So instead, use object variables. They store the values for each object individually.

Ok, so I changed it to object variables. Now each of the slimes have three lives, but I’m confused on how to link the animations of the health bars. Because now all the slimes will display the health bar of the slime I’m attacking, and it will reset when I go to attack another slime.

For example, if I attack a slime once its heart will show twos hearts, and so will every other heart bar. And once there are zero hearts, all slimes will have zero heart with only the one I’m attacking dead. As soon as I attack another slime, all of them will get two hearts.

I linked the heart bar objects to the slimes at the beginning of my code. But I don’t know how to do the individual animations.

You need to move some of the events around. For the issue of all health bars updating, it’s because you aren’t filtering the health bar. Here are the changes you need to make in order for this to work:

  1. Move the change position of the Health_Bar_Enemies to the end of the set of actions that create and scale Health_Bar_Enemies.
  2. Indent the first Repeat for each instance of slime event so it’s a sub event of the Beginning of scene event. And get rid of that trigger once - it’s not doing what you think it should do.
  3. Move the second Repeat for each instance of slime event so it’s a sub event of the Player-Clime collision check.
  4. Move the Slime_Lives check events to be sub events of the Repeat event you moved in step 3.

Note that you may have an issue of the player colliding with a slime and the player suffering health damage event though they landed on top of the slime.