0 like 0 dislike


I'm trying to spawn a single particle, eventually more, that travels to a target's location, then is destroyed when reaching location. My goal is to have it "seeking" the target and to add an arcing path for visual effect. I want it to always end at target's location, so even if the target moves, the particle will adjust. I'm hoping to set a global attribute that I can access inside Unity to spawn a set amount over time, as in 1 per second for 5 seconds, as well as set the location of the shape sampler as the ending target.

Here's an example on youtube where the character channels the ability.


I'm new to Popcornfx and am unsure of how to approach this situation. I've downloaded all the example effects, but couldn't find something similar, the closest maybe being the teslabeam example, but that's using a ribbon. I've gone through the wiki and gone over those tutorials. I'm sure it's a simple problem, but I've been trying to figure out an answer for the past couple of days with no luck.

I also found this post which kind of speaks about what I'm trying to do, although I don't think I need the collision detection aspect:


I specifically wanted to have 1 unity object with the spawner attached so the movement logic is done by Popcornfx, and then spawn a set number as opposed to each bullet having its own spawner/Unity movement logic.

My thought process was to setup a shape sampler which is the ending location. I then tried to lerp between 0 and the ending location and then set the particles position to the result:

SLR = spawner.LifeRatio;

float3 TargetPosition = SeekingMissileShapeSampler.samplePosition();
float3 Pos = lerp(float3(0), TargetPosition, SLR);
Position = Pos;

This sort of works, but the particles movements aren't smooth. I then tried setting the velocity to the lerp result, and the movement is good, but if the target moves after the particle has been created, the position isn't affected and keeps travelling on it's initial set velocity. 

Any help or a push in the right direction would be greatly appreciated. I searched the forums/wiki for an answer before coming here, hopefully I didn't miss something obvious. Thanks for your time.


by Jarryd (170 points)

1 Answer

2 like 0 dislike
Best answer


So you would have several ways to do it, knowing that have the projectile motion entirely done within PopcornFX would make it difficult for your game logic to detect wether the project has hit the target or not. However if you consider that the effect (once launched) will always hit the target because that's what your game logic does, that could work.

Like you pointed out, a very simple way would be to lerp particle Position, however it won't react correctly if the target moves.

I assume what you want is a fixed velocity, that would be possible to be defined as an attribute for example, so as just a very simple starting point you can import this package and see if that fits what you are looking for.

Behavior details:

  • There is a single layer that spawns n particles like a burst (emission duration = 0)
  • Each particle self assigns a field "ParticleID" for later usage
  • At evolve time, it executes first a script evolver which is responsible to determine the new particle velocity with simple math and also kills itself if the distance is < the target radius
  • After that the physics evolver is executed to move the particle Position based on the newly calcultated Velocity
  • Another script is executed computing "RenderPos", a custom field plugged to the billboard renderer, just offsetting the render position with a curve and the "ParticleID" field created at spawn
  • Child particles are spawned using a spawner evolver, rendered as ribbon to give a trail look
I'm sure there are many other ways to do that, probably simpler ones, but that is a start to have dynamic particles, you can then tweak this effect so that it matches your needs.

Hope this helps.

by HugoPKFX (17.5k points)
Thank you very much Hugo, this is exactly what I was looking for.