Have singular GameObject or script ignore Time.timeScale

There’s a part in my game which requires I make the time scale 0 to stop things such as the player moving etc. However, I need a particle effect still actively animating. How can I get the particle to ignore the timescale and continue doing its particle animating?

1 Answer

1

Add this script to the GameObject with the particle system. The particle animation will continue to play

using UnityEngine;
using System.Collections;

public class SimulateDeltatTime : MonoBehaviour
{
    private float lastTime;
    private ParticleSystem ps;

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

    void Start ()
    {
        lastTime = Time.realtimeSinceStartup;
    }

    void Update()
    {
        float deltaTime = Time.realtimeSinceStartup - lastTime;
        ps.Simulate (deltaTime, true, false);
        lastTime = Time.realtimeSinceStartup;
    }
}

Works beautifully! Thanks a lot

–