using UnityEngine; using Game; using Music; using Player; namespace Game { /// /// This class handles the infinite scrolling effect for the background. /// public class InfiniteScroll : MonoBehaviour { /// /// The speed at which the background scrolls. /// public float speed; /// /// The starting position of the background. /// public float start; /// /// The ending position of the background. /// public float end; /// /// Updates the position of the background to create a scrolling effect. /// private void Update() { // If the background moves past the end position, reset it to the start position if (transform.position.x > end) { transform.position = new Vector3(start, transform.position.y, transform.position.z); } // If the background moves past the start position, reset it to the end position else if (transform.position.x < start) { transform.position = new Vector3(end, transform.position.y, transform.position.z); } // Move the background to the right based on the speed and time elapsed transform.position += speed * Time.deltaTime * Vector3.right; } } }