0
\$\begingroup\$

I have set particle system of duration 5 seconds.

But, I wouldn't like particle system to repete but to be frozen in fourth second forever.

How to do that?

\$\endgroup\$
1

1 Answer 1

2
\$\begingroup\$

You can do it with Pause() function of ParticleSystem class. Here is an example;

using UnityEngine;
using System.Collections;

public class ParticleController : MonoBehaviour {

    public ParticleSystem particles;

    // Update is called once per frame
    void Update () {
        //After 4 seconds, pause particles
        if(Time.timeSinceLevelLoad > 4f) {
            particles.Pause();
        }
    }
}

Check here for further information

\$\endgroup\$
5
  • \$\begingroup\$ Thanks, I need to add this script to partcle system which I would like to freeze ? \$\endgroup\$
    – Wildfire
    Commented May 25, 2017 at 11:42
  • 3
    \$\begingroup\$ @Wildfire This script is written in a way that you can put it on anything and then assign the particle system you want to control with it to it by assigning it in the inspector. If you want this to automatically affect the particle system of the same game object, add this to the Start method: particles = gameObject.GetComponent<ParticleSystem>() \$\endgroup\$
    – Philipp
    Commented May 25, 2017 at 11:56
  • 1
    \$\begingroup\$ As @Philip mentions, its for other gameobjects to control a specific particles. If you want tou control particles by itself, then use the code that Philipp posted above, and make the particles private \$\endgroup\$
    – Tolga Şen
    Commented May 25, 2017 at 12:38
  • \$\begingroup\$ Thanks. What if I have multiple particle systems? How to add more lines to assign the particle system in inspector? \$\endgroup\$
    – Wildfire
    Commented May 25, 2017 at 13:43
  • \$\begingroup\$ You can create a public List<ParticleSystem> particleSystems in ParticleController class. That will allow you to use inspector to drag ParticleSystem objects in to the ParticleController. When you enter a positive number other than 0 in the size attribute of the list, the slots will open for you to drag the objects. \$\endgroup\$
    – Tolga Şen
    Commented May 25, 2017 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .