Custom mesh trail in Unity


Hello!
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!

9 Likes

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)

2 Likes

I know Gregory Oliveira has made a custom trail thing before in this post https://twitter.com/godsgreg/status/1178716163489927169?s=20 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.