The problem is in damage infliction

Hello! I made it so that the enemy would inflict damage on me. But when two enemies hit the player at the same time, only 1 damage is inflicted instead of 2. How can I fix this?

Hello, Geldwyr!

I don’t know if your problem will be solved with just that, but using trigger once with the “Repeat for each instance…” will allow it to happen only once (not only once per intance, but only once).

if you remove this trigger, a lot of damage will be inflicted. :frowning:

remove the trigger, and in the health behavior for the player you can add a damage cooldown of 0.5 and that should work

I tested it on 4 enemies and when they hit at the same time, they only inflict 2 damage instead of 4. So it’s not working as intended. :frowning:

I think it’s because your main event is a “Repeat for each instance” using the object “Thug”, but is the HitDamageThug that’s collision with your player and is a subevent of it. I separated these two events and did some tests here and it’s working for me:

  • I add a boolean variable for your Enemy didn’t spawn more than 1 “HitDamageThug” while the animation frame of him is equal or greatear than 8 (and removed the Trigger Once)
  • The boolean variable will be false again when the animation “HitFast1” is over (probably you will need change this variable in another circunstancies of your game)
  • And like I said I sepated the event of colision and put a subevent checking each instance of object HitDamageThug to deal the damage (now it will consider each instance of HitDamageThug)

Edit.: I didn’t put to create the HitDamageThug using a Point called “Hit” so as not to spend time on this detail.

1 Like

This is the way I’d use too - create all the DamageHitThug objects, and then iterate over all that are colliding with the player.

However, I can’t understand how this implementation works. The DamageHitThug is deleted first and then its being referenced. The way I see it, it only works by mere luck. The DamageHitThug should be deleted after the repeat event.

Also, if you link an object, unlink it before it is deleted.

And why is it linked in the first place? Thug is not referred to when checking the collision between DamageHitThug and player.

2 Likes

Hello, MrMen!

I think you are right. Even if the main event is true and there are no conditions in the sub-event, in fact it wasn’t to be able to check the objects if they no longer exist. If I’m not talking nonsense, I remember seeing a post of you talking about a bug related to the delete action. Maybe it’s related? :thinking:
Anyway, @Geldwyr , you’d better follow MrMen’s fix and put the delete action after applying the damage to avoid any future issues. Thanks MrMen!

Wow, I didn’t know that! I’ll check this in my game too! Thanks again! :v:

I didn’t pay attention to that and just repeated the action that was in the Geldwyr print. But is a good question and now I’m curious to know. Tell to us, @Geldwyr :eyes:

2 Likes

Thank you very much, friends! It works! :smiley:

I didn’t pay attention to that and just repeated the action that was in the Geldwyr print. But is a good question and now I’m curious to know. Tell to us, @Geldwyr :eyes:

I was just experimenting)

1 Like