using UnityEngine;
using System.Collections;

public class MoveTo : MonoBehaviour
{
		public GameObject target;
		float speed = 3;
		float distanceToDestroy = 0.02f;
		float lifeTime = 1f;
		// Use this for initialization

	
		// Update is called once per frame
		void Update ()
		{
				transform.Translate ((target.transform.position - transform.position) * Time.deltaTime * speed);
				if (Vector3.Distance (transform.position, target.transform.position) <= distanceToDestroy) {
						lifeTime -= Time.deltaTime;
						if (lifeTime <= 0) {
								Destroy (this.gameObject);
						}
				}
		}
}
