2025-03-03 11:35:56 -05:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class InfiniteScroll : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public float speed;
|
|
|
|
|
public float start;
|
|
|
|
|
public float end;
|
|
|
|
|
|
2025-03-28 17:39:07 -04:00
|
|
|
private void Update() // Moves the background
|
2025-03-03 11:35:56 -05:00
|
|
|
{
|
|
|
|
|
if (transform.position.x > end)
|
|
|
|
|
{
|
|
|
|
|
transform.position = new Vector3(start, transform.position.y, transform.position.z);
|
|
|
|
|
}
|
|
|
|
|
else if (transform.position.x < start)
|
|
|
|
|
{
|
|
|
|
|
transform.position = new Vector3(end, transform.position.y, transform.position.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transform.position += speed * Time.deltaTime * Vector3.right;
|
|
|
|
|
}
|
|
|
|
|
}
|