Unity TrailRenderer Issue

Still developing my new game. Not much to report as I’ve spent most the time doing the tedious bits, like the menu system and save/load stuff, while still coming up with new “obstacles” for the actual game. One particular obstacle is going to be a portal type transporter. When my player (a ball in this particular case) hits the portal it teleports to another part of the scene. At present the player has a trail following it around and I didn’t want this to show during the transition from one part of the scene to the other. Easy, right?

collision.GetComponent<TrailRenderer>().enabled = false;

No compiler errors, no warnings. Everything seems fine. It just doesn’t work… eh? The only other alternative I dug up during a lengthy Google search was to set the time of the TrailRenderer to 0, then set it back to 1 after the transition. Credit to wijesijp for pointing me in the right direction (time) with his post on Unity Answers.

collision.GetComponent<TrailRenderer>().time = 0;

Doesn’t seem ideal but it gets the job done.

Hope this helps someone. At the very least it’ll be a future reminder to myself 😉
Cheers, J

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.