using UnityEngine;
using System.Collections;

public class ScreenWrap : MonoBehaviour
{
	[SerializeField]
	float WidthMax;
	[SerializeField]
	float WidthMin;

	Transform trans;

	// Use this for initialization
	void Start ()
	{
		trans = gameObject.transform;
	}
	
	// Update is called once per frame
	void Update ()
	{
		//If over than max
		if (trans.position.x > WidthMax)
		{
			//Warp to WidthMin
			trans.position = new Vector3(WidthMin, trans.position.y, trans.position.z);
		}

		//If less than min
		if (trans.position.x < WidthMin)
		{
			//Warp to WidthMax
			trans.position = new Vector3(WidthMax, trans.position.y, trans.position.z);
		}

		//warps position.x > Widthmax to 0
		//trans.position = new Vector3(Mathf.Repeat(trans.position.x, WidthMax), trans.position.y, trans.position.z);
	}
}
