# Enemies that follow or chase

I put together a small example here. There are basically two distinct paths for the logic: one for the “x” (left & right) axis, and one for “y” (up & down).

The logic works like this:

1. A Timer wakes up and triggers each second
2. There are two Extractor nodes, one extracts the “x” position of the player, the other extracts the “x” position of the enemy
3. An Expression nodes takes the difference of the two positions (A - B) and sends the result to a Filter
4. If the difference in position is greater than 0, the Velocity is set moving the enemy to the left, otherwise he moves to the right
5. The “y” axis works the same way, only comparing the “y” instead of “x” positions

I used the same thing you used for the fly on my enemie but it only goes to the right it doesnt follow me what should I do?

I can assure you that it works right if you copied it right. Unless you have gravity in your game, it will work.

oh do you know how to do it with gravity?

What you should do instead is remove gravity and add a negative number motor as an [always] on your player so only your player has gravity

What about enemies that chase you on games like this: https://flowlab.io/game/play/106402

in my temple explorer games i make enemies fallow you with a proximity connected to a point-at. It is also connected to a switch and turns it on, and a always is imputed to the switch, and the output is connected to a number (5) to a velocity (forward)

how do you use eval

HEY I just figured that out. Strange how you did the same thing that I did.

I finally under stand

see I made a discussion and eventually answered my own question http://forum.flowlab.io/discussion/734/4-direction-enemies-kill#Item_4

Help! Mine won’t work! And i copied down the behaviors exactly, I triple checked. I also made sure gravity is off and all of the physics of the enemy are matching to the example enemy. I have no clue why mine won’t work. Can you please help me asap! http://flowlab.io/game/view/154128

Ok, I took a look at your game. First off, I really like the characters you have created - nice work so far.

I looked through all the objects and didn’t see any that looked like they had chasing behaviors. Which objects are supposed to chase the player?

Sorry. I deleted the system but I will be attempting to add it back when i get to level three and if I have problems, again, I will message you. And thanks! Ive been working really hard on the game. Its for a community Minecraft Server’s website. But its difficult making with only limited blocks and levels. I would buy unlimited but I just dont have the money for something like this at the moment

Whenever I try making an Extractor extract From Selected Object and choose the player, it doesn’t register, and resets immediately after I click off it. Anyone know how to solve this issue?

@grazer Is there a way I can make walking enemies follow me in a 2D platformer?

@Dan B you have to make the extractor extract from a specific object of the type you want it to select.

Its not working what am i doing wrong?