(Solved) Deleting enemy's charge up bar after it dies

In my game, I have an enemy that charges up an attack before firing, signaled by a bar above it.
when the bar is filled up, the enemy switches to an attack animation.


However, when you defeat the enemy, it gets deleted, but the bar stays, but I want it to be deleted when the enemy dies.

I tried “linking” the two objects together, but I don’t think i’m doing this right…

how do I do this???

Delete both at the same time
And you need repeat for each

Like this?

when you say repeat for each, do you mean duplicating these events but swapping the objects in the “Take into account” event? Bar linked to enemy → Enemy Linked to bar

I meant repeat for each object event type so what you did and what i had in screenshot
This still don’t delete both?
And if not do it at least delete one of them?

It deletes the enemy, but not the charge up bar…

Did you remove your old logic for deleting enemy and bar?

I redid the events to what I showed you when I asked about the for each object. I’ll have to check again.

Okay, so here are the full events i have currently for the charge up bar. is there anything I need to fix?

So compare my events to yours
And spot the difference

As a heads-up, it seems you don’t actually need either the enemy or the bar to be moving.Even so… If you only have one enemy at a time, I’d go for the easy way using the Sticker behavior: enabling “Delete when the object it’s stuck to is deleted.”…basically stick tyhe bar to the enemy..and then delete the enemy.

If there are multiple enemies, though, you’d need a repeat for each one anyway, as Zero mentioned.

THAT FIXED IT!! :tada: I gave the sticker behaviour to the Charge up bar, and it fixed!

Yeah, but that’s just a trick or workaround. ..and if it worked i dunno why it’ s not deleted when you do “delete lifebar”…(probably bcs that unnecessary at the beginning of the scene)..since there is basically 1 object on the screen…

btw…For the future, you should still try to understand what Zero posted above… there’s a 98% chance you’ll run into this later and won’t know how to handle it.

Yeah that’s a good point. I might have to do more research on linking. Zero did give alot of helpful tips.