Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Can I pause a trail renderer?

Discussion in 'Scripting' started by TomBrien, Jun 28, 2012.

  1. TomBrien

    TomBrien

    Joined:
    Apr 28, 2012
    Posts:
    111
    Hey, I was just testing out a slow-mo feature, and I can pause everything in the game fine except Trail Renderers.



    Is there a way I can tell a trail to stop and start simulating?
     
  2. baronsamedi

    baronsamedi

    Joined:
    May 31, 2011
    Posts:
    29
    there is a way, i dont remember specifically but i had the same problem with a similar space type game. pretty sure i had to edit the trailrenderer fadeout time to = 0 or infinity or somethin on pause then set it back to whatever it was previously on unpause.
     
  3. KevinCodes4Food

    KevinCodes4Food

    Joined:
    Dec 6, 2013
    Posts:
    61
    Setting the TrailRenderer.Time to 0 will immediately turn off the trail renderer.

    For one of my games, I wanted to trail to stick around and slowly fade rather then turn off instantly.

    One option we used was to make the trail a separate game object, and unparent from the target when turning off the trail. This would lock the position of the trail renderer and let it slowly fade away. One thing to watch for, though, is that attaching back to the parent again in the future will create a streak as it moves from the last locked position to the updated target's position. You can set time to 0 after the trail goes away to avoid this streak.

    Another option we used is to slowly reduce the TrailRenderer.time value when we wanted the trail off. I had a 2 second length trail for airborne vehicles, and, upon hitting the ground, would reduce the TrailRenderer.time by time.deltaTime * 2 each Update(). It looked good enough for our project. To turn it back on, just set the TrailRenderer.time value to the original value, 2 in our case.
     
    Tom-Mensink likes this.
  4. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Make your own TrailRenderer with desired functionality built in!
    The procedural examples project in the asset store shows how to do this.
     
  5. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    thread is 3 years old.

    sure op doesnt care anymore... might help someone in the future, but meh
     
  6. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Oops!
     
  7. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    not your fault.. you're not responsible for the resurrection of this thread.

    kevincodesforfood must be pretty hungry
     
  8. Tom-Mensink

    Tom-Mensink

    Joined:
    Jul 27, 2017
    Posts:
    17
    @KevinCodes4Food 's answer is the only correct one on the internet!! Thanks Kevin.