Hide linerenderer positions

I have a Line that’s going through a Portal the Problem is that the line connecting the 2 Portals is still visibel. Is there any way to hide lineparts from the linerenderer.

I want that the line part with the red on it is not visibel.

Hi again @OneCode-Official

Are you using a LineRenderer or did you perhaps mean TrailRenderer? I’m guessing this line/trail is attached to your ball that’s going through a portal.

I would suggest using a trail renderer with a script that calls on the “emitting” bool. Whilst emitting is off new vertices won’t be created for the trail, but the old ones stay where they are. Then when you turn it back on again your trail continues from where you are.

Here you can see a game object with a trail attached to it moving through triggers 1 and 2 left to right(Green circles), when they enter a trigger the emitter’s value is flipped:

The code used for this example:

public class TrailRendererStop : MonoBehaviour
    public TrailRenderer trail;

    void OnTriggerEnter2D(Collider2D other) {
        trail.emitting = !trail.emitting;

Hope this helps!

Darksider’s answer is a good suggestion.

The emitting flag in the trail renderer is actually just overriding the trail width to be zero.

So you can emulate the same thing in the line renderer by setting up an appropriate width curve that is zero at the bits you need to hide. You need to know the percentage along the entire line to use this trick.