[SOLVED]How do I flip an enemy when the player or enemy get too close to eachother?

Like the title says, I only want the enemy to flip to the direction of the player when it gets into certain range with one another, I want it to always be looking at the player when it’s in that distance, my enemy objects have boids movement in them so they will be flipping alot often since they will be circling the player.

for now this is what I’m using for the condition.

Also an additional question, my game starts to drop frame rates when enemies start shooting, I already have an event that deletes their projectile when it collides with the walls, and the player but the frame rate keeps dropping until I kill all the enemies in the room is when the framerate recovers.

Hmmm… Maybe try:

 Player distance to Enemy is below 500 pixels
 Trigger once
   -subCondition: player.X() > enemy.X()                 Action: Flip enemy?: No.
   -subCondition: player.X() < enemy.X()                 Action: Flip enemy?: Yes.

This is assuming your sprite faces left by default. The trigger once might also need to need to be moved. I’d have to see more of your events to know whats causing the lag. Did the frame rate always drop so low with that many enemies? Or was it after you added some new events? I’d reccomend watching the “How to optimize your game” on the GDevelop youtube channel.

I dont know if the number of enemies are the problem but once the enemies start shooting then the fps starts to drop, I tried using only 1 enemy in the room and decreased the amount of projectiles it shoots but the frame rate still keeps dropping

Edit: I actually found the problem to the FPS drops, I have a room checker where if the player and enemy are colliding within it will spawn a gate, I actually forgot to put a trigger once event to stop it from creating an infinite amount of gates

I’ve tried this and it doesn’t work

I’ve also tried changing the conditions from yes and no to no and yes and yet it doesn’t work

Update: I’ve fixed the flipping issue, for some reason it’s getting in the way of the if enemy is not in distance of the player below 500 pixels, so I moved it to its own event group and it’s working fine now.