What is the right way to Pause particles?

Hello, may be is is stupid question, but how to pause particles with constant spawn rate.
If I have single burst the function “Pause” is works as it should. But with spawn rate it is reset to default or something like that, and there is a not good looking gap…

I’ve trying to set velocity to 0.0.0 and it obviously didn’t help.

So is there a livehack hot to pause the particles?

There is an example in attach! - wall of moving particles…

Thanks

Hey,

I’m super noob but just in case it can help you somehow. When you click on your graph in the hierarchy you get the little play / Pause… Button in the scene, you can pause it there can’t you ?

Hi @VMaxxx

It might be worth to check the API description, as there’s a good list of available properties etc.

VFX Graph stuff resides in UnityEngine.VFX namespace. See the VisualEffect section: Unity - Scripting API: VisualEffect

My example below gets the VisualEffect component from the current unity object you’ve assigned this script to, then you can adjust the timeScale variable in the Editor UI during runtime, then the effect animation speed changes based on the time scale you set. If you set it to zero, animation is paused. You can use that property to gradually slow down down your effect to a halt, then make it move fast again after a moment. Just as an example.

using UnityEngine;
using UnityEngine.VFX;

public class AdjustVFXSpeed : MonoBehaviour
{
    [SerializeField] float timeScale = 1.0f;
    [SerializeField] VisualEffect VFX;

    void Start()
    {
        VFX = GetComponent<VisualEffect>();
    }

    void Update()
    {
        VFX.playRate = timeScale;
    }
}
4 Likes

Hi @Olmi

Play Rate doesn’t work! playRate = 0 is the same as Pause function. After you return it to 1 it will not resume movement but start it from start. I think it is some how connected with Constant Spawn Rate inner work and it should be paused using some trick)

5544424--570643--2020-03-03_13-43-57.gif

Are you sure about that? Play rate changes particle simulation speed. Is that not what you want to do? It does not cause any sort of discountinuity like simulation restarting if you change the value.

If you want to control particle emission, and pause it, it’s different issue.

Here’s a quick video I made that shows how it works, I don’t see any discontinuities. And it definitely does not start from begininng after you adjust the value.

Hi @Olmi

May be I am just a noob :slight_smile: It is all very strange… Could you please share the VFX graph of your example to compare. Do you use Constant Spawn Rate and just change the VisualEffect.playRate ?

thanks!

It’s very basic, you probably have set something differently. Here’s screenshot of the critical things, output doesn’t really matter as it’s just size, color and so on over the life of a particle.

Constant spawn, randomized 1-3 sec lifetime, and velocity that makes majority of particles go upwards. And that turbulence makes those distortions.

And you do have to do that during play mode, if you adjust the settings… In the case of my example script.

If anyone else is encountering the same problem - if you set/modify velocities directly, then you have to multiply the change by delta time manually, otherwise it will apply them every frame even when timeScale/playRate are set to 0.

2 Likes

Thanks Olmi for sharing the CSharp code. it works well

1 Like