[Solved] Bullet piercing problem

Hello guys,
i have this kind of problem.
the player has a shotgun that pierces enemies and creates damage depending on the distance.
the problem arises when two enemies collide and the bullet sees only the first enemy.
the same thing doesn’t happen if the enemies are far from each other

That bullet collision check makes a list of all tuttinemici it collides with. But when you create, it’s just taking the first one it can get from that list.

To fix this, you need to add a “Repeat for each tuttinemici” as a sub event of the first one. and move the create sangue and create Damage_txt as actions on that new repeat event.

Then make the timer “lunghezza” check events as subevents of the new repeat event.

So you should end up with a 3 deep set of events.

do you mean this?

Yes. Did that solve your problem?

no unfortunately the enemy that is placed behind the other is not subtracted from the hp

Why does the bllet5 animation need to be 0?

And are you deleting bullet5 anywhere?

Also, you don’t need the “If all of these conditions are true” block. If you have a number of conditions in an event, they all need to be true for the event actions to fire.

bullet5 animation is 0 because when the bullet hits a wall it changes animation.

i am not deleting bullet5 anywhere else, it is deleted after 0.7 seconds the bullet comes out and creates damage based on the distance from the player.

if I remove “trigger once” from the primary event, the enemy that is behind receives damage but is subtracted for the entire time that the bullet passes through the enemy, if instead I activate “trigger once” the enemy that is behind the first is ignored by calculating only the first enemy that encounters the bullet.

Yeah, that trigger once is causing the issue. I think it takes the first collision it can get, and leaves it at that. Here’s a very similar problem and a solution for it. You’ll need to add a bit more code to get around this problem, unfortunately.

First add a boolean object variable (call it IsHit) to the members of the tuttinemici group.

Then change the first event to look like :


Then, in the “Repeat for each instance of tuttinemici” event under the 2 create actions, add the action “Set the boolean variable IsHit of tuttinemici to true”.

And finally, before the first event in your screen shot, add the following event :

I think that will solve it.

do I keep something wrong? now the bullet is not as if it no longer saw the impact with any enemy, not even the first one that impacts

Ah, sorry, my bad. I made a mistake. The event I posted earlier should be

The boolean value of variable IsHit of object tuttinemici is false

This bit is wrong :

everything works thank you very much!