Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

peterklogborg commented Dec 8, 2014

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

@PAHeartBeat
Copy link

PAHeartBeat commented Jan 6, 2015

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

@jesliwang
Copy link

jesliwang commented Oct 22, 2016

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