Search Unity

Spline Trail Renderer : New web demo available!

Discussion in 'Assets and Asset Store' started by probesys, Aug 27, 2013.

  1. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    $Spline Trail Renderer - Logo final2.jpg


    A web demo is now available, with brand new assets, and a smooth continuous trail to show the capabilities of the Spline trail renderer!


    $cog2.jpg

    Current features:
    • Draw on the screen
    • Render a trail behind a moving object
    • Draw on a surface (floor, wall)
    • Make an object follow the path
    Upcoming features:
    • A set of trail samples usable out of the box in any application
    This demo and assets will be included in the next release of the package.
     
  2. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Looks really great!!!
    Please make it easy to add or customize trail styles.
     
  3. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Trails can be customized easily with various parameters in the inspector, that can also be modified by code at runtime. Also, you can change the look of a trail a lot by using a texture or a custom shader.


    $inspector2.png


    In the next release we will include new trail samples, new textures and special shaders that will greatly enhance the look of trails, and hopefully inspire people to see what is possible to do visually with the Spline Trail Renderer.
     
  4. jgalvezpa

    jgalvezpa

    Joined:
    Dec 27, 2012
    Posts:
    36
    hello i just wondering if this asset can work with playmaker, right now i'm using unity trail renderer, but is making the line like crap
    in playmaker there is an action called Create Object where i spawn the object that have the trail renderer script, do you think it will work with your asset?
    or do you have a free version i want to be sure before i buy your plugin
     
  5. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Yes it will work. As soon as the object will be instanced by Playmaker, it will begin to generate the trail automatically.
     
  6. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Great work. Can it work on mobile.
     
  7. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Thanks! Yes it works on mobile, but smooth curves like that are quite expensive to compute. On an iPod Touch 4th gen I wouldn't recommend more than 5 trails simultaneously. I have not yet tested on iPad 3 but I guess you could have 2-3x more trails. So it depends on what you plan to do with the tool.
     
  8. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
  9. axCed

    axCed

    Joined:
    May 1, 2013
    Posts:
    13
    We can see at the beginning of the line, when drawing the line, it is flashing. This flashing does not look good. Is there a way to fix that? Otherwise, it seems to be a very good asset.
     
  10. axCed

    axCed

    Joined:
    May 1, 2013
    Posts:
    13
    Hi Olivier,

    Today, we wanted to make some trails behind our boats using you spline trail renderer. We were a little surprise to notice that it does not include width change for the head and the tail of the line. It's a feature we can find with the default Unity trail renderer...

    Do you think you could add that feature to your spline trail renderer. It would help us a lot if you can do that.

    By the way, your spline trail render is not perfect, but it's very good. Thanks. :)
     
  11. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Right now the head and tail either fades completely or not at all. We can include it in the next release, I am sure it will benefit other people too. Thanks for the comment!
     
  12. Harry Nguyen

    Harry Nguyen

    Joined:
    Aug 5, 2013
    Posts:
    17
    Hi Supporter,
    I want Trail is render same TrailSamples for you, but it must render perpendicular with sreen, not must rotate camera same simple for You. I want use it -> do Trail same game Ninja Fruit.
    Please help me.

    --
    Thanks,
     
    Last edited: Nov 4, 2013
  13. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    You can change the trail orientation with the "normal" property of the SplineTrailRenderer component. Usually, your camera will look in the z direction, so you should set the trail normal to look in the -z direction (facing camera) by setting the normal to 0,0,-1.
     
  14. Harry Nguyen

    Harry Nguyen

    Joined:
    Aug 5, 2013
    Posts:
    17
    Ok I done it.
    Thanks
     
  15. Gunhi

    Gunhi

    Joined:
    Apr 18, 2012
    Posts:
    300
    do you have any sample that's working with Playmaker?

    and is this able to make "Hack and Slash" effects on weapons? if so, please create a demo.
     
  16. JeanDenisP

    JeanDenisP

    Joined:
    Jan 9, 2014
    Posts:
    2
    Hello,
    Have you any idea how can I modify some parts of your code to display a spline from a List of positions ?
     
  17. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    You can add a new point like this:
    trailRenderer.spline.knots.Add(new Knot(Vector3(x,y,z)));

    You may need to call trail.spline.Clear() just before adding points from your vector.

    You should not have to modify any of the Trail Renderer's code.
     
  18. JeanDenisP

    JeanDenisP

    Joined:
    Jan 9, 2014
    Posts:
    2
    Yeah, I already tried something like that, I saw Gizmos for my knots but no mesh.

    It's only works if I add points one by one in some update methods. I feel like the MeshRenderer has something to do with my problem but I can figure out what exactly.
     
  19. delibowlen

    delibowlen

    Joined:
    Jan 16, 2013
    Posts:
    57
    Hi, got a (for me) big problem:

    If I instantiate a Trail-PreFab, I can´t even rename it, cause Unity says "NullReferenceException: Object reference not set to an instance of an object "...
    ...any idea? I did it just like every other Instaniate (like in the Reference)

    greetz
     
  20. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    What are you doing precisely? If you look at the PlayerPath scene, trail prefabs are instantiated dynamically, and you can rename either the instance or the prefab without having any error.
     
  21. delibowlen

    delibowlen

    Joined:
    Jan 16, 2013
    Posts:
    57
    thx for the hint.
    i looked into it and found out, that i instaniated the trail as an gameobject...

    i copied that line
    "currentTrail = (Instantiate(trailPrefabs[currentTrailIndex]) as GameObject).GetComponent<SplineTrailRenderer>();"
    and now it works ;)
     
  22. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
  23. aureliocalegari

    aureliocalegari

    Joined:
    Dec 26, 2012
    Posts:
    20
    Great plugin! To my project it would be great if we could set the trail to happen within the local relative space within a parent gameobject that's moving. The way the plugin stands the trail is always in relation to the world space. Is there any easy trick so that we can set it to be in relation to a parent object?
     
  24. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Hi! Yes there is a way to do that, but it requires modifying the SplineTrailRenderer script a bit. You can send me an email, and I will send you the script!
     
  25. aureliocalegari

    aureliocalegari

    Joined:
    Dec 26, 2012
    Posts:
    20
    Hi probesys. I have sent you a private message with my email but got no reply...
     
  26. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Sent! ;) Sorry for the delay, I didn't saw the private message.
     
  27. Ceraph

    Ceraph

    Joined:
    May 16, 2013
    Posts:
    19
    I just picked this up and it seems really useful so far, much better than Unity's built in trail renderer, but I'm running into some inconsistency when trying to get a trail rendered behind the player as they move. For roughly 90% of the frames the trail gets rendered from the correct position, but every 1/10 frames or so the spline jumps ahead of the player a bit and causes the trail to be rendered ahead of where it should be. This causes the trailer to look very jittery as it follows the player. I've tried making my width extremely small (0.01) so I'm sure it's not an issue of the chunks being to large to be generated smoothly. Turning on the debug option for showing the spline the spline appears to actually be ahead of the position of the object containing the SplineTrailRenderer script.

    Any ideas why this would be happening or how to fix it? All of my player movement is using Unity's 2D physics system and everything happens in FixedUpdate.
     
  28. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Thanks Ceraph for the feedback. Turns out I ran into the same problem just yesterday... I don't know yet what causes this happen, I'll investigate it, and come back to you as soon as I find a solution.
     
  29. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    It seems to be a bug introduced in the last update by an optimization feature. For now you can simply disable the feature, I will push a fix to the asset store soon. To do that, you can edit SplineTrailRenderer.cs, and at line 19 set shiftMeshData to false instead of true.
     
  30. Ceraph

    Ceraph

    Joined:
    May 16, 2013
    Posts:
    19
    Thanks for the help! That seems to have solved the issue with the spline, but now it looks like the mesh generated is lagging behind the spline for a few frames then it jumps ahead and catches up to the spline. Then it starts lagging again for a few frames, catches up, etc. etc. It's kind of hard to tell but as near as I can tell it looks like the mesh was lagging behind the spline with shiftMeshData set to true as well.
     
  31. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    What do you mean lagging? Could you send me a video of it?
     
  32. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Hi,
    is there a "always facing to the camera" mode? I mean dynamically for moving cameras.
     
  33. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    It's not built-in no, but there probably is a simple way to make it happen, depending on your needs. You can write to me directly and describe in more details what you need to do.
     
  34. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi, i have a problem using the spline trail renderer and contacted with the creator via e-mail, so a suggested to post that in the forum in case any other encounter a similar problem.

    $weird.png

    And here is the answer, that i have to check as soon as i go home:

    Cheers!
     
    KillMobil likes this.
  35. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi, again.

    I've tried to change the code making add only the points of the path when it is calculated the first time, but as soon as the character moves the path changes and the points number changes too. So i don't think if the problem is there. The weird rendering is he same. The right part of the path in the screenshot isn't rendered, and in the left it renders only the closing segment of the path that i don't know where it is created, because it closes the path adding again the start point. I only set the spline knots with the navmesh path waypoints. Any idea, please?

    I think it hasn't to be that difficult to make a simple path, but i can't see were the problem is.


    Thanks!
     
  36. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Can't you simply move the trail renderer GameObject when you trace the path?
     
  37. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    I did, but the same result!
     
  38. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Any idea?
    :)
     
  39. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    I am sending you a unity package by email, with an example of how to do it :)
     
  40. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Thanks a lot! I'll try it tomorrow!

    Cheers
     
  41. bravo

    bravo

    Joined:
    Dec 31, 2012
    Posts:
    6
    Hi,
    I need to manually trace spline in scene, save it with all knots and recreate it at the start of the scene: What is the best way to do it?

    thanks in advance
    Brago
     
  42. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Hi,

    You can create a spline from points like this:

    SplineTrailRenderer trail = yourSplineTrailRendererGameObject.GetComponent<SplineTrailRenderer>();

    foreach(vector3 v in yourVector3Array)
    {
    trail.spline.knots.Add(new Knot(v));
    }

    You may want to clear the trail points when drawing a new path:

    trail.Clear();

    Hope this helps!
     
  43. brendan-vance

    brendan-vance

    Joined:
    Jan 16, 2014
    Posts:
    36
    Hey,

    There appears to be a bug in the current version (1.2) where if the trail has to expand its vertex array greater than the increment amount (say the increment amount is the default 200 and it needs to be 368 indexes longer) the code will only add 200 rather than the required 368; it will therefore hit an IndexOutOfRange exception when the RenderMesh() function attempts to remap the vertices.

    I think I've resolved the issue by modifying part of the Reallocate function to look like this:

    Code (csharp):
    1. int incremented = allocatedNbQuad;
    2. while(incremented < nbQuad) {
    3. incremented += advancedParameters.nbQuadIncrement;
    4. }
    5.  
    6. if(incremented * NbVertexPerQuad > 65000)
    7. {
    8. Clear();
    9. return;
    10. }
    11.  
    12. allocatedNbQuad = incremented;
    -Brendan
     
  44. KillMobil

    KillMobil

    Joined:
    Dec 3, 2013
    Posts:
    29
    I am getting some shader errors upon exporting. Any ideas or solutions for this?

    Code (CSharp):
    1.  
    2. Shader compiler: internal error compiling shader snippet type=0 platform=0: Error polling external process
    3.  
    4. Shader error in 'Custom/ColorFade': Internal error communicating with the shader compiler process
    5. Shader error in 'Custom/ColorFade': cannot implicitly convert from 'const float2' to 'half4' at line 27
    6.  
     
  45. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    Hi! I tested it, and it works fine on my side, for what platform, did you build it? And what Unity version?
     
  46. tolosaoldfan

    tolosaoldfan

    Joined:
    Sep 14, 2012
    Posts:
    92
    Hello,
    Yes same issue with the ShaderCompiler when building for WebPlayer with U3D4.6.8.f1 and the last version of SplineTrailRend downloaded today (October 15).
    "Shader error in 'Custom/ColorFade': cannot implicitly convert from 'const float2' to 'half4' at line 27"
     
    Last edited: Oct 15, 2015
  47. probesys

    probesys

    Joined:
    Aug 26, 2013
    Posts:
    56
    I don't know why this is not working anymore, but apparently you need to replace IN.uv2_StubTex, by this IN.uv2_StubTex.x at line 27 of the shader.
     
  48. tolosaoldfan

    tolosaoldfan

    Joined:
    Sep 14, 2012
    Posts:
    92
    Works now. Thanks
     
  49. tolosaoldfan

    tolosaoldfan

    Joined:
    Sep 14, 2012
    Posts:
    92
    Thanks Brendan for the fix !
     
  50. KillMobil

    KillMobil

    Joined:
    Dec 3, 2013
    Posts:
    29
    Another thanks From me!