40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Runtime.CompilerServices;
|
||
|
using System.Threading;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class ScrollableBackground : MonoBehaviour
|
||
|
{
|
||
|
//[SerializeField] private GameObject background;
|
||
|
[SerializeField] public float speed = 2;
|
||
|
[SerializeField] private double minYPosition = -14.78;
|
||
|
[SerializeField] private float maxYPosition = 10;
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
float deltaX = Input.GetAxis("Horizontal"); // Vertical
|
||
|
float deltaY = Input.GetAxis("Vertical"); // Vertical
|
||
|
|
||
|
Vector3 movementDirection;
|
||
|
movementDirection = new Vector3(0, -1, 0);
|
||
|
|
||
|
transform.Translate(movementDirection * speed * Time.deltaTime);
|
||
|
|
||
|
//background.transform.position += Vector3.down * speed * Time.deltaTime;
|
||
|
|
||
|
//if (background.transform.position.y <= minYPosition)
|
||
|
//{
|
||
|
// background.transform.position += Vector3.up * maxYPosition;
|
||
|
//}
|
||
|
|
||
|
transform.position += Vector3.down * speed * Time.deltaTime;
|
||
|
|
||
|
if (transform.position.y <= minYPosition)
|
||
|
{
|
||
|
transform.position += Vector3.up * maxYPosition;
|
||
|
}
|
||
|
}
|
||
|
}
|