When more than one of the same enemy hits at the same time, the player only takes damage from one same enemy

In the game I made, the enemy gives damage to the player, it does normal damage to an enemy, but when more than one of the same enemy hits at the same time, it only gives the damage of an enemy, not multiple damage.

how can i solve this?

You might try using the “For Each” condition.

yes ı try but same

this is cod:

As a heads up, using “Trigger once” in a for each event means “only do this once”. So it will only occur for the first instance that is in collision.

If you want it to only occur once per each enemy, you’ll need to add some kind of variable to the enemies, like “haveHitHero” and make it a condition of the event that it is currently false, then set it to true once the hit occurs. Then reset it to false when not in collision with hero.

Although note: many games tend to do some kind of invulnerability frames after getting hit, not just let enemies pile up on the hero.

actually the problem is that if i don’t use the trigger once, normally the enemy should deal 1 damage but it does 1 damage nonstop

Unfortunately, that doesn’t change what I posted.

You cannot use trigger once with for each object events. It won’t work for all of the objects like you expect.

Adding a boolean variable and doing both the conditions and actions like I mentioned will also help you avoid the damage every frame issue.

if you can can you show an example image for it?

I think @Silver-Streak is doing it the right way by teaching you how to do it instead of showing you.
Altho sometimes just looking at things clears it up a lot. But i would like to redirect you to the GDevelop 5 [GDevelop wiki] because this is really basic stuff that is very well documented.

But for now, this is a way you can do it: