Help with infinite line

Hi, i am having trouble making a 2d game with 4 separate lines on which the player(dot, or cube) would move, they need to be infinite lines. i have some ideas about creating them with line renderer?
not looking for a specific solution, rather a direction or advice on where to start.
138591-untitled-1111.jpg

Hello.

I dnt know if its the best solution, but if i have to do this i would do little different.

For the image, i can imagine all time the lines go in same direction (they crosss each other, but always go ahead), so i would have several lines segments as a prefab, and instantiate them continusly in front and delete then once out of scene.

This way, will have only few line objects in scene at same time, and can be instantiating new lines to the infinite.

Bye!

here is the code, try this

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test : MonoBehaviour
{
    private LineRenderer[] lines;
    private int currentPosition;

    void Awake()
    {
        currentPosition = 2;

        lines = new LineRenderer[4];
        for (int i = 0; i < 4; i++)
        {
            GameObject lineParent = new GameObject();
            lines *= lineParent.AddComponent<LineRenderer>();*

lines*.startWidth = 0.5f;*
lines*.endWidth = 0.5f;*

lines*.SetPosition(0, new Vector3(i, 0, 0));*
lines*.SetPosition(1, new Vector3(i, 0, 1));*
}

StartCoroutine(NextIteration());
}

public IEnumerator NextIteration()
{
while(true)
{
yield return new WaitForSeconds(1f);

if(Random.Range(0, 5) == 0)
{
Shuffle();
}

for (int i = 0; i < 4; i++)
{
lines*.positionCount = currentPosition + 1;*
lines*.SetPosition(currentPosition, new Vector3(i, 0, currentPosition));*
}

currentPosition++;
}
}

private void Shuffle()
{
int index1 = Random.Range(0, 4);
int index2;

do { index2 = Random.Range(0, 4); } while (index2 == index1);

LineRenderer tmp = lines[index1];

lines[index1] = lines[index2];
lines[index2] = tmp;
}
}

so far i have managed to create 4 lines, randomly generated to always stay within the borders of the screen. but can’t quite figure how to stop them going one over another… here is screenshot maybe it will help explain better what is happening.