using UnityEngine;
using System.Collections;

public class EnemyMotion : MonoBehaviour {
	
	public float delta = 1.5f;  // Amount to move left and right from the start point
	public float speed = 1.0f; 
	private Vector3 startPos;
	
	void Start () {
		startPos = transform.position;
	}
	
	void Update () {
		Vector3 v = startPos;
		v.x += delta * Mathf.Sin (Time.time * speed);
		transform.position = v;
	}

	void OnCollisionEnter2D (Collision2D other){
		if (other.gameObject.tag == "Player") {
			Destroy (other.gameObject);
			Application.LoadLevel("Forest");
		}
	}
}