using UnityEngine;
using System.Collections;

public class FloatingText : MonoBehaviour {

	float floatTime = 2f;
	float speed = 1f;

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		floatTime -= Time.deltaTime;
		if(floatTime <= 0)
			StopFloat(); 

		transform.Translate( new Vector3(0, speed * Time.deltaTime, 0) );
	}

	public void StartFloat(string text) {
		GetComponent<TextMesh>().text = text;
		transform.localPosition = new Vector3(0, 0, -0.1f);
		gameObject.SetActive(true);
		floatTime = 2f;
	}

	public void StopFloat() {
		gameObject.SetActive(false);
	}
}
