Custom mesh trail in Unity
I’m a solo dev making games with Unity. So far I’m making everything myself, including effects.
This script I’ve been working on started with me wanting better looking rocket flames in one of my games, and I decided to ditch using long stretchy particles, and started fiddling with mesh generation instead.

I felt Unity was missing a mesh trail that can be manipulated, have force applied to it and so on. So I tried making one.

Turns out the more I play with its settings and shaders the more effects I realize it could potentially be used for (I tried to showcase that in the video above).

The reason I’m posting this is to ask you fellow fx loving people if there is any interest in something like this, or if someone else like me felt it missing. I’m thinking of cleaning it up and putting it on the Asset Store, but that would require quite some time and effort.
Any comments or questions are welcome :slight_smile:

It must be said that right now the mesh trail is very much 2D but that might change in the future.

To use it you simply add a script to a Game Object and it starts spitting out mesh.
Then you give it a material with a shader assigned to it and you’re good to go.
The script itself has properties a bit like a particle emitter, like life time and starting speed, but most of the tweaks and work is done in the shader.

Noteworthy features are:

  • Editor previewing (play mode not required), this was important to me
  • Useful data like lifetime left is sent to shader through vertex colors
  • Optional world space force to every trail point, useful for faking gravity or wind

Well, that’s pretty much it. Here follow some gifs from development for anybody interested:

First thing was to make the emitter emit moving connected points with a limited lifetime
Then adding vertices to each point, also here red vertex color represented lifetime of each point
Start of material and UV work, also width expansion and randomness
Playing with shader, mesh still buggy (fun fact: it’s 28 verts)
This is how it ended up in the game

Hope you enjoyed reading!


I have struggled with Unitys default trails because they are lacking something like this. a-lot the corners overlap and the start/ends glitch out which make it very annoying. I’d like to play around with making one of these for myself as well. I know that a few fx artists and tech people have made their custom trails as well because Unity refuses to update theirs.

Man this is awesome and i would really want to try this, are you planing on realeasing it in asset store? :slight_smile:
The current trail, even with ribbon mode, does not offer exatly the same thing and is often quite ugly from my point of view.

1 Like

Cool man. Yeah I’m having some issues with overlapping aswell sometimes. Usually it can be tweaked away with current settings though! Do you have links or such for other custom trail work that you mentioned?

Thanks a lot, your words motivate me :slight_smile:
If you send me a PM with somewhere to send it I can send it to you when I’ve cleaned it up a bit and removed a couple of bugs! (That goes for anybody reading this, really)


I know Gregory Oliveira has made a custom trail thing before in this post I still have zero clue how to make this.

My idea would be to use the same sort of particle mechanics from the default unity system and draw mesh between them, maybe even just Slerp after the end/start particles die to stop the mesh from bugging out.

just my two cents

Gimme the goods <3

please and thank you.

Hey again!
I cleaned this up a bit and submitted it to the Asset Store a couple of weeks ago but it was denied. I created a topic here that has a package attached for you to try/use if you want. Your feedback is much appreciated :slight_smile:


Hmm, I shall give it a go when I can, what were the reasons the package was rejected?

The reason was that the package was “too simple for our current standards”.

That’s really crappy way of thinking of things from unity’s side. Do you know if this works using HDRP? I think it wont, but if you could get it to work using that, I think you could re apply :smiley:

Hehe, I don’t see why it shouldn’t work using HDRP, I mean all the script really does is generate and manipulate mesh over time :slight_smile:
The included demo scenes might look messed up though, haven’t been tested

Great job!
Perhaps you have a similar solution for a 3D trail?

Hey, thanks!
I haven’t really touched this stuff since a year back, maybe couple of tweaks here and there.
I have used it in one or two 3d projects though, it can work depending on what it is you are building, you just have to keep in mind how it is rotated.
I’m curious, what are you planning on using it for more exactly? I could maybe make some changes to it if I knew your requirements :slight_smile:

I need the beast to see smell that follows the victim like a trail. Your cigarette smoke effect would be a great solution if I could use it as a 3d trail.

Ok cool! Could you draw me a picture, like, is the camera from the beast’s first person point of view, or is it top down in a 3d environment, or something inbetween?

In game mode, we see the beast from the third person. The victim scent trail should look like the picture

I see, I see. I tried a bit and my trail doesn’t really cut it in 3d, but it’s close. Would probably need to rework it quite a bit, there are a couple of pretty big problems that arise in using all 3 axis.
By the way, why is it Unity’s built-in trail doesn’t work for you here?

Here’s a gif of the cigarette effect (slightly modified values; no forces, no speed) in 3d viewport

I also tweaked the cigarette smoke in a similar way but using my own shader for it. This option could work for me if the texture was tiled rather than stretched. Is it possible to tile a texture in your trail?

There is a problem with the Unity’s built-in trail.
When trail follows the character, the texture also moves very quickly along the trail. And it looks really bad. When the trail stops moving shader works correctly (like on attached gif). I am trying to find a solution to this problem but with no success yet.
Perhaps you have an idea how to solve it?

Yes, you can tile the texture in Trail2D.
Example here:
But you can kinda do that in Unity’s trail renderer also:
Just set Texture Mode to Repeat Per Segment, and I think you can tweak it into acting how you want it.