(Solved) For each event Bug

Hello, I want to report a bug. I tried to create enemy AI for my game in GDevelop, but it doesn’t work, even though I’m doing everything correctly.
Here’s the code to confirm:

Hi,

Unfortunately you are not telling us what should happen and what doesn’t work.

Not really. In your events you are using a Trigger once-condition within a Repeat-event. This doesn’t work the way you think. For checking the collision of your objects you don’t need a repeat-event. Just try to use the collision and trigger conditions with the subevents as a normal event.

A lot of time people add the ‘Bug reports’ tag and claim that they found a bug in the engine although the issue is in their events. Checking twice and asking in the forum first is often the better way to get something working.

1 Like

Sorry for my mistake.
I was planning to make it so that when the enemy touches the object group, it plays the turning animation and then changes direction.
However, with this new information (the Trigger Once condition), I can now solve this myself.
Thank you very much.

1 Like

No need to be sorry. I am glad that you get it working.

1 Like

That’s a common misunderstanding. Another common issue is the last 2 line. They’re creating a sort of chain reaction.

Events are processed from top to bottom. The last line undoes the actions of the previous line.

If left set to right
If right set to left

You can use a boolean toggle instead. See #3
https://wiki.gdevelop.io/gdevelop5/tutorials/how-to-make-togglable-states-with-variables/

2 Likes