I’ve been having issues with my shmup project, I developed a level scrolling system which would place the first tile that exits certain bounds into the last tile’s position, which is working well - except that after placement there is a 1 pixel gap between the tiles. This happens in both scene and game view.
Using pixel perfect camera, 320x180 resolution with 20 assets pixels per unit, all assets are imported with 20 pixel size
The code for this implementation:
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class LevelScroller : MonoBehaviour
{
private Vector2 lastTile;
public Transform[] tiles;
public int scrollSpeed;
// Start is called before the first frame update
void Start()
{
// getting transform of the LAST tile in the list
lastTile = new Vector2(tiles[tiles.Length - 1].position.x, tiles[tiles.Length -1].position.y);
Debug.Log(lastTile);
}
// Update is called once per frame
void Update()
{
for (int i = 0; i < tiles.Length; i++)
{
tiles[i].transform.Translate(Vector3.down * Time.deltaTime * scrollSpeed);
if (tiles[i].transform.position.y < -9)
{
tiles[i].transform.position = lastTile;
Debug.Log(tiles[i].transform.position);
}
}
}
}
I’m also open to other approaches, the intention for these tiles is to eventually hold obstacles such as breakable barrels etc.