How can I make it so only Instances that meet the conditions do an action?


I am using TopDownMovement to create a side beat um up game and have several of the same type of enemy in the Scene at once. I only want those instances that meet the conditions face me. For example

{if Player X() < Enemy.X()… Then {Flip object horizontally}
{Inverted condition… Don’t Flip}

It works but it is applied to all Instances, so if I am between two Enemies one will be facing me correctly but the other will have it’s back to me. I am sure I am missing something very simple but I am only a few hours into using this program so any help would be welcome.

Second question is how can i make it so the player can not walk through the enemy? If I use Separate two objects it forces them to move in a way that does not look natural. I have tried using collision but I have trouble with that as well.

Thanks in advance for the help.

Can you show a screenshot of your actual code? Can your player move in all directions?

for each: For each object event - GDevelop documentation

Hello Sab!
Try switching the event around so you’re comparing the enemy x to the player x rather than having the player x first. I’m just theorizing but if it’s checking the x position of the enemies first and foremost it should have an action that only applies to the ones being positively checked.

  • Obee