Some of the enemies in my game have a glow stuck to them, using the stick action. How do I cause the glow to automatically be destroyed when the enemy is? Thank you!
Are they literally touching the enemy? I would try if glow not in collision enemy group delete glow but not sure that would work. So then if that failed I would try, in my delete enemy event I would say delete glow at enemy.x enemy.y. Or maybe I would try, if glow in collision with enemy and enemy variable health = 0 delete glow. If all else fails show us some events someone will figure something out.
Good ideas! I think the enemy health variable might be the trick. Thank you!
The only thing I’m worried about is if your enemies touch each other, then the glows will touch each other and might disappear if the wrong enemy health = 0. But in that case we’ll have to figure something else out. If you’re using an extension there might be a way to tell if it is stuck to an enemy and enemy health = 0 then delete it.
When you stick the glow object to the enemy, you could link them. Then before you delete the enemy you use Take into account linked objects to repick the linked glow object. You can then delete both objects.
https://wiki.gdevelop.io/gdevelop5/all-features/linked-objects#link_two_objects
I just noticed the sticker behavior has a condition to check if an object is stuck to something. It’s in the other conditions section. If you’re using the sticker, you wouldn’t even need the linking. Although, I kind of like linking.
I added this based on the “is stuck to” idea:
It didn’t work. Unattached glows still stay around.
I don’t know if it works inverted. My thought was when the enemy is about to get deleted through some condition like health is dead then use the stick to condition to pick any glow objects. And then delete them both. The enemy would have to be picked first.
Here’s the event block I’m using that seems to be working pretty good. Thanks for the suggestions!
For the first event, I suggest you unstick the glow before you delete the 2 objects. It has the potential to cause problems behinds the scenes.
Thank you for that advice. I have added that!