[Solved] Collision behavior

who of you has ever noticed that when we make a collision be it with a bullet or with a melee attack the collision point we assign hits more than one enemy at the same time … in the case, for example, of 2 or more overlapping enemies with a bullet they hit everyone, how is it possible to avoid this ?? the trigger once command does not work

for example, of 2 or more overlapping enemies with a bullet they hit everyone, how is it possible to avoid this ??

This depends on a few things. If you don’t tell it to stop damaging other enemies once damage has occurred, then yes, every enemy will still be damaged by it.

In the case of the bullet, you can assign a variable “DamageOccurred = 1” when the bullet has hit the first enemy, and in the condition that damages the enemy also check if the “DamageOccurred” variable of the bullet is 0 (zero).

Variables are always my best friends :fist_right: :fist_left:

But have you tried this ??? it works?? because I’m trying with an object variable called attack … but it doesn’t work … can I ask you the courtesy to paste me an example ??? you know … take a screenshot of what you say about gdevelop

I have indeed tried this.

This is how you can do it:

This of course, is a really simple example, take that in mind.

Hum I don’t understand … in case the enemy has life points ??? because in this example i see a simple condition that in case it happens the enemy vanish in this case it works even without the variable … using repeat for each you got every single enemy even the way you used the variable … i didn’t try. . but in the end it is set to 1 even if it hits 2 enemies … have you made some mistake or am I not familiar with the system ???

Like I said it was a simple example. You can add things like health and bullet damage.

In the example, the conditions are explained as follows:
First the bullet hits an enemy, then for each enemy it checks if the bullet hasn’t hit an enemy yet.
But the first enemy in the “for each” condition will set the bullet as being used.

Try the example, you will see that it works. You can then add whatever you need.

ok my friend… not working… i tried… maybe cause is melee attack?? and a collision is repeted?

Can you provide a screen snip of the events so far?. We can only hypothesis to what’s beend one, and it will most likely be that the events need a slight correction to work.

this is enemy creation a object “hiteasybarb” is a collision point

when a player is in collision whit vision… starting attack

this is your suggest… not work for me… i have laredy try to change a repeat for each enemy whit player and other

That is confusing. What is this meant to be doing?

  • you’re checking for HitEasyBarb with Player
  • then repeating for all HitEnemy - how is that related to HitEasyBarb or Player?
  • then you reduce Player’s Hp by a variable on Enemy. Where did that come from? There are no conditions to select or filter Enemy? So if I’m not mistaken, it’ll reduce Player’s Hp by the Dmg of every Enemy on the scene.

Is HitEnemy is an object group? If so, what are it’s members?
Is HitEasyBarb linked to HitEnemy?
Is HitEasyBarb linked to Enemy?

I’m making some grand assumptions here, but I’m guessing what you’re after is :

Enemy is a group… inside have a enemy called easybarbarian
hitenemy is a group whit a sprite linket to every enemy for collision “hitEasyBarb”
hit easy barb is linked to easy barbarian… when start attack animation “1” go in collision whit player

That isn’t linked in the conditions. GDevelop doesn’t know which ones are linked.

Anyway, as I understand it:

Each EasyBarbarian is linked to one HitEasyBarb object.
EasyBarbarian has a variable Dmg
Enemy has EasyBarbarian as a member

In which case, my previous code snippet should be what you’re after. Let me know if it works.

yea you have understund… and no… not working

What is it doing? I need a bit more to go on.

seem now working i just not use a group…