I have a problem, I have two enemies that are the same but when I collide with the first one, it performs an attack, but the second one also does it. I already applied the solution for each one, but they still perform the attack at the same time.
I assume you’re using something like “Enemy collides with Enemy”, with the action “Change animation of Enemy to attack”, or something similar.
Look at it from GDevelop’s PoV - which of the two enemy objects are you referring to? It doesn’t know, and so applied the action to both.
As MrMen said, both objects are being picked. So, you need to narrow it down to one object. The easiest would be to add pick a random object. There are many ways to choose just ine of them.
The raycast X detects collision against a wall and randomly changes direction, upwards, downwards, leftwards. The raycast is removed and created at the position to which it is directed to detect collision. The problem is that when two enemies like him collide, they both change direction. The first one to collide makes the other also change direction when I only want the one that caused the event to do it. Another problem that I think is related to the same issue is that when one of them attacks, the other also performs the animation of attacking
Why are you repeating for each raycastX? What are you trying to do here?
The condition on the bottom is not needed - the animation will alway be “Right” because it is set in the first event.
Yes, because of this:
That condition will choose all Armadillo that are moving right, and perform most of the actions on all Armadillo that meet the conditions. You’ll need to add a “Repeat for each Armadillo” as a first subevent, and all other existing subevents should become subevents of the Repeat event. Something like:
The solution didn’t work, I implemented it, but when they collide, the recognition raycast is removed, meaning that it collides with the wall and appears again in a random place, but not inside the object
Sorry, it did work. I was just applying it incorrectly. Thank you very much, and I hope to be able to share the progress of my project with you