How can I create universal movement barriers that work on all enemy sprites?

Right now I have made different barrier sprites for every platform that change the direction of the enemies in collision. But if I continue this way the project will start becoming very chunky.

I also have tried using an enemy group with a variable to limit excess code, but when one enemy sprite reaches a border then the whole group starts moving towards the opposite direction.

Is there a way to create just 2 barriers that I can later use on all platforms?
And also maybe use an enemy group instead of adding every enemy one by one on the event?

Thanks!

Yes, you need to use “for each” events.
Please see the documentation.

Do I also have to add different barrier sprites, for every platform ground? Or is there a way to have just 2 (one that moves enemies left and one that moves them right)?

I haven’t tried it, but I think even one might be enough. Then in the events: “if player is flipped, do this” “if player is not flipped, do that”.
Or two of them, if you want to spare yourself a headache :grimacing:

Thank you!. I’ll give it a try