How to make particles follow a complex linear path?

My goal is to create a dynamic laser beam that is being emitted from the center of GameObject A towards GameObject B where it is reflected until it hits GameObject C. A continuous pulsing beam line with some particles floating along the length of the beam.

I’ve written a raycasting script to compute the individual positions at runtime, but by problem at the moment is just getting the basic VFX behaviour to work - how to draw a beam which moves from A to B to C in straight lines.

The “Genie” from the VFX graph example package looked extremely promising as it essentially does what I need just with extra steps, but it seems to depend entirely on the “Sample Beziér Curve” node and there’s no corresponding “Sample Linear Path” node or anything along those lines. I’ve got it to work with the old trailRenderer component, but that’s too limiting in terms of visuals.

At the moment I’m thinking about just creating a VFX graph that draws a single line and linking several of them those, but I’ve the feeling that there must be a simple solution I’m just not seeing. And in the long run I’d like to have some beam characteristics (like pulses) that travel across the entire beam, so I’m a little worried just linking individual beams together now might cause a lot of headaches later on.

Any ideas how to best approach this problem?

Hi @Ramjid ,

You can lerp between point A and B when the particle lifetime is 0 - 0.5 and then from point B to point C for a lifetime between 0.5 and 1:

If you need more complex behavior, you can calculate the distances between Points A, B, and C and adjust the timing accordingly.

You may also be interested in this thread which talks about more positions and randomly spawning particles between them.

Hope this helps!

2 Likes

Thanks a lot @VladVNeykov , with the help of your example and the thread you linked I got my laser beam working pretty much exaclty the way I wanted!

1 Like