Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class RepeatBackground : MonoBehaviour
- {
- private Vector3 startPos;
- private float repeatWidth;
- // Start is called before the first frame update
- void Start()
- {//equals the postion of the background
- startPos = transform.position;
- repeatWidth = GetComponent<BoxCollider>().size.x / 2;
- }
- // Update is called once per frame
- void Update()
- {//when the backgound pos is less than 50 on the x it goes back to the start position
- if (transform.position.x < startPos.x - repeatWidth)
- {
- transform.position = startPos;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement