Teleporting trail renderer

I have a trail renderer on a game object, I am teleporting said game object, when I do this the trail briefly forms between before and after the object was teleported. I would like to prevent this. How may I do this?

This is a 2D project, and I am using c#.

If you have any questions, please do not hesitate to ask, any help is much appreciated.

Thank you

Trail Renderer now has a clear function, it may have been added to Unity after this question was asked. After you have moved the object call Clear and you shouldn’t see the line.

Alternatively; if you don’t want the trail to suddenly disappear at the position the object teleported from you can create a copy of the object where you want to teleport it to and enable auto destruct on the original.

Why not just disable the TR just before changing the transform.position, and enabling it again afterwards?

Setting the trail renderer’s time to 0, waiting a frame, then restoring the time works:

function ResetTrailRenderer(tr : TrailRenderer) {
    var trailTime = tr.time;
    tr.time = 0;
    yield;
    tr.time = trailTime;
}

An untested C# translation (would be called with StartCoroutine()):

IEnumerator ResetTrailRenderer(TrailRenderer : tr) {
    float trailTime = tr.time;
    tr.time = 0;
    yield return null;
    tr.time = trailTime;
}