这是背景往前的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BackgroundCollectorL : MonoBehaviour
{
float width;
// Start is called before the first frame update
void Start()
{
width = GameObject.FindGameObjectWithTag("BG").GetComponent().size.x;
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "BG")
{
Vector2 temPos = other.transform.position;
temPos.x += width * 2;
other.transform.position = temPos;
}
}
}