Problem with relation between collision condition and for each condition


Basically, I have a simple scene where the single instance of object is being created(spear), resized with scaling and then its checking for collision with instances of other objects(blue enemies).

The problem is that I can’t make it to work in reliable manner where it executes an action only once for every collided monster1 object. The closest thing I managed to do is in pic related, where two closest instances are being affected (probably because they are affected on the same frame?), but two others aren’t.

Here is the sample condition:

If I remove “trigger once” then every monster is affected, but game logic is broken.
If I use “trigger once” then game logic is correct, but It seems that it only checks for collision once (despite trigger once being below collision check).

Can somebody explain this to me and tell me what’s the correct way of implementing this?

Hello, gigakoks

That’s true because you are using trigger once with “Repeat for each instance”. Try to remove your trigger once and use a boolean variable in your enemy. Something like this:

This will cause it to occur only once for each instance.

In another event you can change this variable to true again (maybe after the tween effect).

Like @Rasterisko remove the “Trigger Once” - it acts on all the objects, not just the one in the repeat loop - and use a boolean to track whether or not the enemy had been hit.

As it stands the monsters will incur damage without moving the spear away and striking them again. If you want to only inflict damage with each separate strike of the spear then use the following to achieve that:

Ok, I got it to work. Thanks.