How to do a trail

I would like to have a trail when fly around. Something like this

Did somebody something like this or do you have an idea how I could achieve something similar? Can that be done wit particle system? I guess not or I don’t know how or what particle shape I should use.


I use an effect similar to this for weapon trails. Basically, it is just a custom mesh that periodically adds a new edges. You would have to remove edges at the end and add them to the beginning.

So there is actually nothing out of box then :smile:


You could do this using Particle Emitters if you attach them to your moving object. If you call .setInWorldSpace(true) on the emitter, then the particles will stay where they are, leaving a trail. This is how I do all of the basic trails for spells with my game. You could even use the default grayscale effect image for smoke that’s included with the engine to test it out: Effects/Explosion/smoketrail.png

Not really. You could probably fake it a little if you did a particle emitter that emits world position particles and had a circle texture on it. You would have to emit a lot of particles though and you could go through weird periods where you would move to fast and there would be gaps.

yes exactly my experience, the gaps are very uncool.

Yeah the particle emitter isn’t necessarily the best way to go for every effect, although I’ve found you can use them for pretty much anything and sometimes it will look good, other times it won’t cut it.

The best way I’ve been able to combat the issue you mentioned is by drastically increasing the amount of particles on the emitter, and make sure the values you set to the 'lowlife, ‘highlife’, and ‘particles per second’ don’t cause the emitter to use up all of its particles before the old ones disappear. But still particle emitters can appear more imperfect depending on the specifics of the effect your’e going for.

1 Like

I did now a google search and maybe this space-fight/src/de/jlab/spacefight/effect/trail at master · rampage128/space-fight · GitHub is a good starting point…

The cinematics area of the engine provides a useful demonstration of what you see. It is for the spatials n stuff but the math is there. You give it waypoints and it will calculate the kind of curvy line you are looking for. I guess you just throw a bit of gentle noise in the width of that line and maybe even the texture.

1 Like

Ok it makes a curve with a spline, but I guess I have to update that curve ever frame (or so) with a new way point. So I guess have to create a custom mesh or the like to achieve this. Or I don’t see how I could use MotionPath for that, maybe how the curve is done (the math from there).

Not only that, I have to remove the oldest segment (after a while, after given number of way points).

But I slowly start to have an idea to do it, at least some points are now clearer for me, like how to make a curve and not a blocky line.

You don’t have to “remove” things from the mesh, just overwrite them in round-robin fashion. That way you only have to update one quad of the buffer at a time.

1 Like

There is a waypoint listener. When a waypoint is reached and it has reached your limit, say 20 points, remove the first point in a FIFO fashion and add the next. Also, there is a debug shape you can use to work out the geometry side.

Edit: as Paul mentioned, you can actually work out a few short cuts to the procedure and optimize it better as you achieve the desired effect.

1 Like

Or perhaps GitHub - MisterCavespider/Lina: This is is a library for jMonkeyEngine3. It adds support for different kind of lines, which make it easy to trace objects.


Thanks. Maybe that’s the closest thing of what I‘m looking for.
Would be cool if would have some sort of a knowledge base to hold all the cool stuff :smile:

thx all for the various helpfull and interesting pointers and ideas.

1 Like

trails ?

I’m pretty sure I used this.

1 Like

cool. yes exactly this.