ParticleSystem.SetParticles kills trails with "Die with Particles" disabled

Hi,

I’m modifying my particles using GetParticles/SetParticles in a script. My particles have Trails module enabled and its “Die with Particles” property is set to false. It works fine on Unity 5.6 and 2017.2 but on 2018.4 and 2019.1, my trails do die with the particles. I’ve narrowed down the issue to the SetParticles call. If I call it, my trails whose particles have died will be killed instantly (even though “Die with Particles” is disabled). The preview screen shows the number of alive particles as ~60 on 2017.2 but this number is ~30 on 2018.4.

To reproduce the issue:

using UnityEngine;

public class ParticlesIssue : MonoBehaviour
{
    private ParticleSystem particles;

    private void Awake()
    {
        particles = GetComponent<ParticleSystem>();
    }

    private void Update()
    {
        // Creating an array in Update is inefficient but this is for testing purposes only
        ParticleSystem.Particle[] arr = new ParticleSystem.Particle[particles.particleCount];
        int aliveParticles = particles.GetParticles( arr );
        particles.SetParticles( arr, aliveParticles );
    }
}

At runtime, trails behave correctly when the script is disabled but they start disappearing immediately when it is enabled.

I can open an issue but I am looking for a workaround for current Unity versions, if possible.

Any feedback is welcome.

I think it is caused by a bugfix to prevent old trails from hanging around when using SetParticles (because we don’t get/set the trail data, we don’t know whether to reset it or preserve it when using SetParticles.)

You can report an issue and we will look at it, but I suspect that is something that will only get fixed by a new feature to allow the trail data to also be get/set. (I.e. not a fix that can be applied to already released versions)

1 Like

This still seems to be an issue in 2020.3 - did anyone report this?

I don’t remember reporting this. I guess I was too busy with work at that time that I’ve forgotten about this.

1 Like

From a quick test, it seems that if you use the newer C# particle job system to set the position, then the trails don’t die when the particle dies :slight_smile: YAY!

1 Like

Defy still a bug in 2021.2.10 with standard get/set method. I’ll report it later this week.

Case 1405484

3 Likes