Emit Particle Trail Continuously with Fast Movement (2D)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ben Humphries

I am working on a dash mechanic for a KinematicBody2D, using a Tween node. It essentially ramps up the velocity and then brings it back down very quickly, resulting in a “dash” that still works with physics. I have a particle trail following the player’s feet as if it is dust, but when the player dashes, it moves so fast that the system only emits from about 4 distinct places on the path (4 frames of the player dashing).

What would be the best way to emit particles continuously across the path that the player moves?

Here are some images to convey what I’m talking about:
walking trail
dashing trail

:bust_in_silhouette: Reply From: A112Studio

Bump the amount of emitted particles :slight_smile:

This doesn’t work because for any given frame in the dash, the player is only in one of 4 discrete positions. All it does is increase the density at those points.

Since the particle system is a child of the player and has the same position, it’s emission will only be from those 4 points, no matter how many particles are released.

For example, the position value of the player may look like this during walking (with x’s as values):

-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x

And like this during a dash:

x------------x--------------x--------------x

Ben Humphries | 2020-05-10 17:36

Assuming that your character is moving in a straight line between frames, can you store the previous position and the current position per frame and then calculate the points along the line and emit particles along that line?

Would that work?

Moo | 2020-05-10 22:13

I thought of that – the only caveat is that I imagine emitting all of those particles at once along the line would make it look like 4 “sections” of similar particles that all disappear at the exact same time. Maybe the answer is to dynamically change the lifetime of the particles as I go down the line?

Another thing is that I’m not too familiar with the particle system in Godot – is there a good way to emit particles one by one from a script like that? Remember that this all has to be in one frame.

Ben Humphries | 2020-05-11 03:10

:bust_in_silhouette: Reply From: SassySnorlax

Hi Ben, try to set the ‘Explosiveness’ property in the Particles2D inspector. Setting it to a higher value will make the the particles emit more rapidly.

So you could either increase the value of Explosiveness while you’re dashing and set it back to normal after the dash is completed - or - you could make another particles2D scene to activate while dashing.