using UnityEngine;
using System.Collections;

public class Waypoint : MonoBehaviour 
{

	public int speed = 1;
	public bool goingLeft = false;
	public bool goingRight = true;

	void Update()
	{
		if(transform.position.x < -4 || transform.position.x > 4)
		{
			goingLeft = !goingLeft;
			goingRight = !goingRight;
		}
		if(goingLeft)
			transform.Translate(-speed * Time.deltaTime,0,0);
		else if(goingRight)
			transform.Translate(speed * Time.deltaTime,0,0);

	}
}
