Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by slehmann101 · Sep 23, 2014 at 03:25 AM · movementteleporttrailrenderertrailtrail renderer

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by robertbu · Sep 23, 2014 at 03:54 AM

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;
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image slehmann101 · Sep 23, 2014 at 11:52 PM 0
Share

Thank you, that worked perfectly. Seems slightly hacky to have to do it like this... It is the kind of thing that you would expect unity to have in their API's...

avatar image siaran · Mar 02, 2015 at 01:57 PM 0
Share

Problem with this method is, it doesn't actually restore the trail's length, it just starts making a new one from the new location. So it still doesn't actually teleport the trail.

No, I don't have a solution that does that (I've been looking for one...), just thought I'd point that out.

avatar image
2

Answer by Binarin · Sep 07, 2016 at 03:23 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Cherno · Sep 24, 2014 at 01:25 AM

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

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ickydime · Aug 13, 2015 at 10:46 PM 0
Share

Does not work. It seems to pick up where it left off when you reenable.

avatar image engelhard90 · Jan 23 at 02:15 PM 0
Share

It works for me! Thanks

avatar image engelhard90 · Jan 23 at 02:16 PM 0
Share

But it restarts the particles...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make a trail particle effect for an object that zig zags on the screen? 0 Answers

How to make bezier curve and trail effect for 2D puzzle game? 0 Answers

Unity Trail Renderer acts ... differently on MAC 0 Answers

Trail renderer overlapping 0 Answers

Trail renderer with physics? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges