How to make a enemy follow player when looking at them?

Hello, I am trying to make a game where if the player is in sight of the enemy then it will go toward the player but i have no idea how to do it

it should be easy with ray casts but idk if that’s how its supposed to be used.

can someone please help me i have no idea what i am doing as I said…

Before you come back here check if every X in your events is on par with X on my screenshot same goes for Y and same goes for > < signs

To find if one of these condition and if all of these conditions
Click on add new condition and type OR and for other one AND

Now what it does (so you can delete/adjust stuff to your needs)
From top to bottom
IF x pos of player is lower than x of UFO (enemy) so enemy is on the right from player
IF player y pos is higher than y of enemy + 10 pixels down
IF player y pos is lower than y of enemy - 10 pixels up
If enemy is not horizontally flipped (looking to the left)
Distance between player and enemy is less than 40 pixels

And in action you have just move enemy to toward player

While other part of condition is exactly same as above with 2 differences
1 - checking if player is right from enemy (player x position is higher than enemy x)
2 - checking if enemy is looking left (enemy animation is NOT flipped so it is looking right)

I didnt explain right my bad this is what I meant

so when the player is seen the enemy moves toward the player

nvm just realized this is exactly what i needed :man_facepalming: thank you!!

1 Like