Skip to content

Instantly share code, notes, and snippets.

@AlexTiTanium
Created May 30, 2013 08:27
Show Gist options
  • Save AlexTiTanium/5676482 to your computer and use it in GitHub Desktop.
Save AlexTiTanium/5676482 to your computer and use it in GitHub Desktop.
Time scale independent Particle system in unity3d
using UnityEngine;
using System.Collections;
public class ParticaleAnimator : MonoBehaviour {
private void Awake()
{
particle = GetComponent<ParticleSystem>();
}
// Use this for initialization
void Start ()
{
lastTime = Time.realtimeSinceStartup;
}
// Update is called once per frame
void Update ()
{
float deltaTime = Time.realtimeSinceStartup - (float)lastTime;
particle.Simulate(deltaTime, true, false); //last must be false!!
lastTime = Time.realtimeSinceStartup;
}
private double lastTime;
private ParticleSystem particle;
}
@peterklogborg
Copy link

void Update ()
{
particle.Simulate(Time.unscaledDeltaTime, true, false)
}

@PAHeartBeat
Copy link

when TimeScale set to 0 simulate not working in my project i don't know whats wong

@jesliwang
Copy link

Thanks, This help me much!!!

@OrDuan
Copy link

OrDuan commented Dec 25, 2016

If you want to make it a bit more performance wise, You can add this code at the beginning of your Update():

if (Time.timeScale > 0.001f)
{
    return;
}

Helps when you have many ParticleSystem

@Lyyua
Copy link

Lyyua commented Aug 7, 2017

Now you can use ParticleSystem.playbackspeed instead

@temresen
Copy link

temresen commented Nov 2, 2017

Now, in Unity 2017 there is a Delta Time option which we can set to Unscaled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment