using UnityEngine;
using System.Collections;

public class TravelToPlayer : MonoBehaviour {

	GameObject PlayerShip;

	public Vector3 BubbleTarget;

	public float projectileSpeed = 5f;

	// Use this for initialization
	void Start () {
		PlayerShip = GameObject.Find ("Player");
		BubbleTarget = PlayerShip.gameObject.transform.position;
		Invoke ("FailSafeDestroy", 2.5f);
	}
	
	// Update is called once per frame
	void Update () {	
		//transform.position = Vector2.Lerp (transform.position, BubbleTarget, Time.deltaTime * bubbleSpeed);
		transform.position = Vector2.MoveTowards (transform.position, BubbleTarget, Time.deltaTime * projectileSpeed);
		if (transform.position == BubbleTarget) 
		{
			Debug.Log ("bubble die");
			Destroy (this.gameObject);
		}
	}
	void FailSafeDestroy()
	{
		Destroy (this.gameObject);
	}
}
