TouhouLS/Assets/RealCode/Animations/SimpleScrollLoop.cs

27 lines
593 B
C#
Raw Normal View History

2020-08-22 05:29:00 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleScrollLoop : MonoBehaviour {
public float width = 8.75f;
public float speed = 1f;
private float value = 0f;
public Transform one, two;
private void Update() {
if (speed > 0) {
one.localPosition = new Vector3(value - width, 0f, 0f);
two.localPosition = new Vector3(value, 0f, 0f);
} else {
one.localPosition = new Vector3(value + width, 0f, 0f);
two.localPosition = new Vector3(value, 0f, 0f);
}
value += Time.deltaTime * speed;
value %= width;
}
}