Quick answer: Call trail.Clear() immediately before the teleport and the long warp segment never appears. For warps that should preserve the trail logically, toggle trail.emitting = false, teleport, wait one frame, then set emitting back to true.
Player dashes through a portal. The trail behind them now draws a perfectly straight line across the level connecting the dash entry to the dash exit. It looks like a graph plot, not a movement effect.
The Symptom
After any large transform jump — teleport, respawn, level transition, scene reset — the TrailRenderer draws a continuous segment connecting the previous and current positions, with the trail trailing behind the new location.
What Causes This
TrailRenderer samples the transform position each frame and connects consecutive samples into a triangle strip. It has no concept of “intentional jump.” A teleport between Update calls produces two adjacent samples that are far apart, and the connecting strip is just as visible as any other segment.
The Fix
Pattern 1: Clear before teleport.
public class PortalTeleport : MonoBehaviour
{
public TrailRenderer trail;
public void Teleport(Vector3 destination)
{
trail.Clear(); // drop buffered points
transform.position = destination;
}
}
Clear() empties the trail buffer instantly. The next sample (current frame, at the new location) starts a fresh trail.
Pattern 2: Suppress emit across the warp.
public IEnumerator DashTeleport(Vector3 destination)
{
trail.emitting = false;
transform.position = destination;
yield return null; // skip a frame
trail.emitting = true;
}
This preserves trailing tail points up to the warp moment but doesn’t draw the connecting segment. The trail naturally fades behind the warp origin while a fresh trail begins at the destination.
Don’t Just Disable the GameObject
Disabling and re-enabling the TrailRenderer GameObject doesn’t reliably clear — some Unity versions retain the buffer across enable cycles. Use Clear() explicitly.
Multi-Step Teleport (Sequence)
For cinematic teleports involving multiple positions (charge-up, dash, settle), Clear once at the start and then let the trail draw the actual sequence.
Verifying
Trigger a teleport in PIE. The trail should not draw a segment between origin and destination. Both should have independent trail behavior — old fades naturally, new starts fresh.
“Clear before, or stop emit across, the teleport. The warp segment disappears.”
Related Issues
For LineRenderer UV issues, see LineRenderer UV. For pooled trail renderers leaking, see trail leak on pool.
Clear before teleport. The line across the level disappears.