using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Distance : MonoBehaviour {
	public Transform tFrom, tTo;
	public float fDistance;
	// Use this for initialization
	void OnEnable () {
		this.GetComponent<Slider>().maxValue = Vector3.Distance(tFrom.position,tTo.position);
		this.GetComponent<Slider>().minValue = .1f;

	}
	
	// Update is called once per frame
	void Update () 
	{
		fDistance = Vector3.Distance(tFrom.position,tTo.position);
		this.GetComponent<Slider>().value = fDistance;
	}
	public float GetDistance () 
	{
		fDistance = Vector3.Distance(tFrom.position,tTo.position);
		return(fDistance);
	}
}
