using UnityEngine;
using System.Collections;

public class Platform : MonoBehaviour {

	public Vector3 end1;
	public Vector3 end2;
	public bool back = false;
	public float errorMargin = 0.1f;

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		if(!back && transform.position != end2)
			transform.position = Vector3.Lerp(transform.position,end2,0.02f);
		else if(!back && transform.position == end2)
			back = true;
		else if(back && transform.position != end1)
			transform.position = Vector3.Lerp(transform.position,end1,0.02f);
		else if(back && transform.position == end1)
			back = false;

		if(Vector3.Distance(transform.position,end1) <= 0.1f)
			back = false;
		if(Vector3.Distance(transform.position,end2) <= 0.1f)
			back = true;
	}
}
