21 lines
451 B
C#
Raw Normal View History

2024-11-29 21:37:01 +08:00
using System;
using UnityEngine;
public class BackgroundScroller : MonoBehaviour
{
public float ScrollSpeed;
public float TileSizeZ;
private Vector3 _startPosition;
void Start ()
{
_startPosition = transform.position;
}
void Update ()
{
float newPosition = Mathf.Repeat(Time.time * ScrollSpeed, TileSizeZ);
this.transform.position = _startPosition + Vector3.forward * newPosition;
}
}