Animating 2d AI

I have this script which lets my enemy follow my player:

public Transform Player;
	public float speed = 2f;
	private float minDistance = 0.2f;
	private float range;
	void Update ()
		Player = GameObject.FindWithTag ("Player").transform;
		range = Vector2.Distance(transform.position, Player.position);

		if (range > minDistance)
			Player = GameObject.FindWithTag ("Player").transform;
			transform.position = Vector2.MoveTowards(transform.position, Player.position, speed * Time.deltaTime);

but I want the enemy to animate depending on where it’s facing. For instance:

If the enemy is moving left, play the Walking left animation.


Hello Zoogyburger,

you need to check in which direction your enemy follows the player, run the animation with accordance to the movement of the enemy i.e in which direction enemy is moving and turn on the animation for same direction.

Ankush Taneja