What is causing my key not to show when I kill two enemies?

I am tryna make it where a key shows up on my u.i. Layer when I kill 2 enemies. But it won’t show up and I’m honestly lost on what I have done wrong. Any help would be greatly appreciated🙏

The first picture is the code that uses a variable to tell how many deaths have occurred and then sets the scene variable to spawn the key. The code is located at the bottom of the HEALTH/DEATH TAB

The second image is where I have it set to the variable of Spawnkey is true to make the key visible.

Are the two screenshots of 2 different scenes? If so, the scene variable won’t transfer from one to the other.

If the Key/Hell Door events are in external events, then have you checked what the value of AmountOfDeaths is? I don’t think it’ll get to over 1 for an Axe_Demon. Also, that Trigger once when checking the animation is “Death” will allow one of the Axe_Demons to change it’s health, but none of the others.

1 Like

When I remove the trigger once, the key shows up when I kill just one of the axe demons, but when it’s on there it doesn’t show up at all. And the key/hell door is an external event that is linked to the main scene. With the trigger once on there they both are still killable it just doesn’t seem to add the variable right.

See the key showed up but I have only killed one of them, it’s like it’s not counting the variable amount correctly

Yes, because the event is being actioned repeatedly. From what I can make out, you are iterating over every Axe_Demon object every game frame (so about 60 times per second), creating new health bar:

updating it and increasing the AmountOfDeaths value:

You should be creating the enemy health bar when the Axe_Demon is created and updating the enemy health bar when the damage is inflicted.

WRT the key, do you want the it to appear once an Axe_Demon has been killed twice? Because that’s what it seems like with the current events. You are using an instance variable, so it’s specific to one instance of the Axe_Demon object. If you kill 2 Axe_Demons, they will both have their AmountOfDeaths set to 1.

Or do you want the key to appear once 2 of the Axe_Demons have been killed and are in the death animations? Use a scene variable instead then.

Or, if you don’t delete the Axe_Demon objects, you could just create an event to count the number of Axe_Demon death animations are in the scene.

1 Like

I’m tryna make it spawn when 2 of them have been killed, ima try the using a scene variable, thank you

I tried using the scene variable it still had the same effect. nothing changed. This should be a simple process I feel like, idk what i’m doing wrong to complicate it. I even tried moving it to where it wasn’t a part of the each instance code and still had no effect on it spawning.

with it being in the each instance code

Without it in the each instance code

Idk how to what events to use to count the number of axe demon deaths are in the scene

Implement these changes, and update the scene variable axedemondeaths as a subevent when the damage is inflicted. It’s just too messy and illogical as it stands.

1 Like

idk how that would work because of how i have it set for the axe demon to take damage, he takes different levels of damage depending on the attack the knight performs.

where the axe demon takes damage

where the axe demon is spawned

My bad im still extremely new to this

You could add one more variable to the Axe_Demon object, say named “DamageTaken” (default to 0). In the events where you reduce the Axe_Demon’s health, instead set this new variable to the damage amount.

Then in your axe demon event sheet, do this instead of iterating over the axe_demon objects all the time, do this: