Enemies follow all area2ds

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Newby
:warning: Old Version Published before Godot 3 was released.

My enemies follow the player and each other pls help
CODE

var motion=Vector2()
var body=get_node("Area2D").get_overlapping_areas()
if(body.size()!=0):
	for tinge in body:

		if(tinge.get_global_pos().x<self.get_global_pos().x):
			ORIENTATION_NEXT="left"
			anim="Idle"
			anim_speed=1
			move(-speed, accel,delta)
		elif(tinge.get_global_pos().x>self.get_global_pos().x+5):
			ORIENTATION_NEXT="right"
			anim="Idle"
			anim_speed=1
			move(speed, accel,delta)
		else:
			move(0, accel,delta)
		rotate_behavior()

And this code is inside which script, that is attached to which node?
It is very hard to tell what is the problem based on this snippet alone. Please describe what are you trying to achieve and how you went about doing so.

Artium Nihamkin | 2017-10-14 13:53

the script is attached to a rigidbody2d i have made a child node of an area2d as the enemy range i made the said code above the enemy moves when player is in range so i added two enemies. started testing everything was fine until my enemies went next to one another. they just stay stuck to one another following each other. WHAT I WANT IS THE ENEMY TO FOLLOW THE PLAYER AND ONLY THE PLAYER

Newby | 2017-10-14 22:45