using UnityEngine;

public class EnemyGroup : MonoBehaviour
{
	public float speed = 2f;
	public float dropAmount = 0.5f;

	private int direction = 1;

	void Update()
	{
		// Move left / right
		transform.Translate(Vector2.right * speed * direction * Time.deltaTime);

		// Change direction at edges
		if (transform.position.x >= 6f)
		{
			direction = -1;
			DropDown();
		}
		else if (transform.position.x <= -6f)
		{
			direction = 1;
			DropDown();
		}
	}

	void DropDown()
	{
		transform.position += Vector3.down * dropAmount;
	}
}

