using UnityEngine;


namespace GameEngine
{
	public class WrapBehaviour : MonoBehaviour
	{
		[SerializeField] private Transform m_Transform = default(Transform);
		[SerializeField] private float m_WrapDistance = default(float);




		private void Update()
		{
			Vector3 pos = transform.position;

			while (pos.x - m_Transform.position.x < m_WrapDistance)
			{
				pos.x += m_WrapDistance*2f;
			}

			while (pos.x - m_Transform.position.x > m_WrapDistance)
			{
				pos.x -= m_WrapDistance * 2f;
			}

			transform.position = pos;
		}
	}
}
