Custom ribbon effect for bullet trails

Hi guys. I want to make a Niagara scratch pad module, to which I would pass the start and end of the ribbon to be rendered as a bullet trail but with single emitter. I can do a similar effect through creating a Lead particle emitter (with persistent IDs on) and listen to its Location event with the Following emitter with ribbon renderer. The problem is it draws the trail incrementally and I end up having 100 of particles for single trail while it is enough to have only start and end particles and move them. I guess a scratch pad module can do the job if we process pairs of two particles (start and end) and draw a ribbon between.

Yes you can do that. You probably don’t even need a scratchpad.
-Spawn two particles (burst)
-OnParticleSpawn: Set your start location (wherever you spawned the bullet)
-OnParticleUpdate: Set the position of the particles to: Lerp position, A = Position; B = Bullet Position (if your system is attached to the bullet, ‘Owner Position’)
That should do it.

Sounds like you just want a quad, in that case you can just use a sprite renderer:

If you want the starting position always follow the actor (the emitter itself is in World Space), you will need to set Particles.Position with Simulation Position in Particle Update:

image

1 Like

I guess the benefit of it being a ribbon would be the ribbon mesh rendering options. Tube or crossed planes might work better than a single quad from certain angles.
But I do like your quad solution :slight_smile:

In fact we use the similar logic of the quad on a cylinder mesh for a laser effect, but there isn’t a one size fit all solution. So I think it’s ok if the OP prefers ribbon.

Hi, guys. Many thanks! This is not quite what I need. I guess both these solutions works only if one has one trail per one Niagara system and spawn a system for every trail, this is very performance heavy!
I want to produce multiple trails for multiple bullets with single emitter in single Niagara system. And from what I have discovered there are two good solutions:

  1. Modifying Niagara script that creates ribbon. One ribbon group for all particles what makes Niagara connecting them in a single line instead of having multiple separate segments. We can assign a unique ribbon ID for every two particle pairs and we get a trail between them. This would require some custom logic and script modification but should be doable.
  2. Second option is Niagara data channels. This would break world in cells and if event occurs in cell that already has Niagara system this would add an emitter to it, if it does not it would create Niagara system and add emitter to it. This way we have just a few Niagara system and potentially endless emitters inside. This is a new feature epics released tutorial on. Less performant then option 1 but easier to set up just following the guide and also more versatile.

I did not implement either :slight_smile: if I do i will update the post.

If you can use the quad solution, it’s actually quite easy to just spawn multiple trails in one emitter.
Just have a very high spawnrate and make sure your nr of particles matches / does not exeed the nr of trails.
Then feed the bullet positions in as an array. And then you do the same logic, but your target position reads from the array. So each particle reads one entry of the array for it’s target location.
With ribbons it’s slightly more complicated, as you need to assign a ribbon ID for each trail. But also possible. Similar to this:


BlockquoteHi, guys. Many thanks! This is not quite what I need. I guess both these solutions works only if one has one trail per one Niagara system and spawn a system for every trail, this is very performance heavy!

How many trails do you actually have at any one time?
I mean it’s good worrying about performance, but it might not even be that heavy if it’s not many. To optimise you could also pool-spawn them, then you don’t get the overhead of spawning / despawning.
In addition you can do visibility & distance culling.
So if it’s < 100 trails I would proabably profile first before making assumptions about bad performance.

Ah, at first I did not got the quad idea. This would work! And also I could spawn quads in a manner of crossed planes or use cylinders. Great solutions thank you both!

And linked tutorial is also very interesting!