Detecting sprites on the same x-axis

I’m making platformer shooter and I want the enemy to start shooting if the player is on the same flooras them (x-axis) but I don’t know how to do so. Any help would be greatly appreciated, thanks in advance! :grin:

There is a great tutorial by Wishforge about getting the enemy to detect the player > How To Create Advanced Enemy AI in GDevelop Free Game Engine - Tutorial - YouTube

1 Like

Ok thanks for the help! :slight_smile:

1 Like

You just have to evaluate each enemy X position compared to the player X position. Do it trough a “for each…” loop. (If you don’t know what a “for each…” loop is, consult the wiki).

I recommend you to evaluate each enemy X position against a range (for example, from player.X - 25 to player.X + 25) instead of the exact player X position.

1 Like