I’m trying to make a particle strip trail for a moving object. Here’s requirements / situation:
Have a VFX which is attached to an object
When the object moves in any direction, it should leave a particle strip behind to show as a trail
The motion direction is defined by force at runtime, there’s no fixed forward axis of the object motion - it may tumble and rotate
Here’s what I’ve done so far:
Set a VFX asset as a child for the object to inherit motion and transforms
I’m spawning particles over distance so that there’s no trail if the object is stationary
This way I’m getting particles in the world when the object moves, but to generate a particle strip the particles needs to be moving
To give particles motion I’m setting the velocity of the particles in the opposite direction of the particle’s current position to initial spawn position of the particle. As the motion will be almost linear this estimates the direction of motion
I then trigger events over time for the particles to create a strip
Now the issue is that the motion of the particles looks very spread around the start and doesn’t feel like a trail because of that. What would be the best way to setup something like this that results in a more natural trail behavior?
The other way I can think of is to pass off the current motion direction of the object via a script to the VFX graph and set the initial velocity of the particle to that, but can this be achieved without resorting to an external script?
You can find motion (direction) by creating vector from previous source position and current one, so you don’t need additional script.
In any case I am not sure what exactly the problem is, you want particles to be spawned closer to local origin? Make them less affected by force/speed?
Do you have reference picture of effect you need? If not, please describe or draw how you want your vfx to look like.
BTW your spawn position is using float instead of vector3
Thanks for pointing out that the get property block was using a float - can’t believe I missed that.
What I want is the trail to conform to the path of the object completely, and right now the current behavior is a bit more spread around the start (even after fixing the get property block to vector3). Here’s an image illustrating what I want vs what the current situation is:
However, if you want them to actually move with ball or in opposite direction you can use oldPosition.
This attribute is set by SpawnOverDistance by default and you can use that to find current movement direction. The thing is - you don’t need to set velocity every frame, just do it once, unless you need to create some specific behaviour.
Changes in your initial graph:
Thanks for the replies, they are very insightful.
I do want the trails to move in the opposite direction, so the second behavior is what I’m after.
I wasn’t aware of the oldPosition attribute, this should be really handy. And you are right, I don’t need to do it every frame if I can get the proper data at init stage.
Thanks again for your replies, you are a lifesaver