Calculate the damage inflicted

sorry but I’m still having problems…
this is what happens:
bug
the second enemy suffers the hit twice while the third is not counted

I don’t know why this is for each player. It should be for each enemy
image

I think. My bullets weren’t as close together.

My current events

all updated, fingers crossed

To include a tween, I think this works.

unfortunately no it doesn’t work
examplegif

Well. What’s happening is my concept isn’t exactly like yours. I wasn’t using groups. I just rewrote it with groups and I’m going to see what the issue is. It seems to be when multiple objects collide. it might need a scene variable instead of the pick all. The pick all is picking too many.

Ok, so I added a scene variable Boolean variable called IsLinked. The inverted link condition just wasn’t working as expected. And trying to repick just 1 bullet and enemy wasn’t working. It’s easier to use the current pick list.

Try me: (I added a health display to check that everyone was getting the correct damage)
(I added 2 bullets using left or and right mouse button)
https://gd.games/instant-builds/db21e0fa-d8fc-4945-94c9-a82ba9360162

All of the current events

I’m going to update my GitHub.

Version 3.
https://github.com/doug13579/gdevelop-multiple-bullet-one-time-hit-3

1 Like

great! works!! thanks for everything @Keith_1357

1 Like

I was writing the events in my project but I realized that if the projectile is eliminated in collision with the enemy the hit is not calculated
prob

Try deleting the bullet after everything else.

1 Like

Im no expert on this subject but i use the command apply damage to object to apply damage.

ok it works sorry again

I feel that the solutions being suggested are getting over-complicated. Linking makes sense for a text that you want to continuously update on-screen… but not so much for a bullet that is flying through many objects.

Also, you shouldn’t be repeating for bullets AND enemies. Just do:

repeat for each bullet
   bullet is in collision with enemies   |    do damage to enemies

Anyway as for the problem itself, I would give the enemy object a new variable to count the damage taken. Then you can subtract the damage from both the enemy HP, and the enemy damageTaken variable at the same time. When you want to display the text, set it to damageTaken. When you want the number to reset, set damageTaken to 0.

It probably needs to be double checked but it’s a complex issue. kevino93 wants the bullets to pass through the enimies but only cause damage once. So, each bullet needs to be checked. The damage text is also reused as it’s tweened upwards. Once it gets deleted another text onject needs to be created.

I initially tried using object IDs and an array but that seemed over overcomplicated.

Ah, in that case you could use Trigger Once:

repeat for each bullet
   bullet is in collision with enemies   |    do damage to enemies
   trigger once while true               |

As I said before, linking is the way to go for updating the text while it tweens. However instead of deleting it, and creating it again, you could just keep reusing the same object.

repeat for each bullet
   bullet is in collision with enemies   |   add bullet.damage to enemies.HP
   trigger once while true               |   add bullet.damage to enemies.damageTaken
   ------------------------------------------------------------
       take into account text linked     |  text = enemies.damageTaken
       to enemies                        |  
       ----------------------------------------------
           tween finished on text        |   tween text


tween finished on text                   
trigger once
   ---------------------------------------------------
   take into account all enemies         | enemies.damageTaken = 0
   linked to text                        |

That’s just a quick sketch of course, If I can find some time tomorrow maybe I’ll make an example project

The trigger once condition works on an object level not instance. Adding it would prevent multiple bullets from being detected at the same time.

Normally it wouldn’t be an issue because the bullet is usually deleted when it hits something. In this case they go through the enemy and that’s fine. It just makes things slightly more complicated.

No, I’m already repeating for each bullet, which is required for multiple simultaneous hits to be treated individually (for example if you want an impact effect to appear in each position). The trigger once is a sub-event, so for each bullet, as it hits enemies it should damage each of them once.

hmm… I’m trying to make an example project and there are issues :stuck_out_tongue: stand by