Stop trail, move object and reactivate trail

I am using a pool for a certain projectile that has a trail attached. The problem is that when the object is deactivated, moved and reactivated, the trail draws the complete path of movement between the spot it deactivated and the new one.

I tried disabling the trail renderer when the projectile is disabled in the OnDisable call and reenabling it in the OnEnable call, I also tried the same with trail.emitting setting. The code that moves the object is called before the projectile is SetActive but I guess that doesn’t matter.

Any ideas?

So I’m having trouble recreating this issue out of the box with 2017.3.0f3. I’ve created a trail renderer component on an empty game object in a scene, and added a simple script to move it around via code while it’s inactive but I’m not getting the behavior you’re describing.

I have had a similar problem in the past though, and I was able to remedy it using the TrailRenderer.Clear() function. Without knowing more about your project though, I don’t know if this would be a viable solution for you.

The Clear() method seems to do the trick. Weird that it didn’t come up in any of my searches about this. Thanks