Created
May 30, 2013 08:27
-
-
Save AlexTiTanium/5676482 to your computer and use it in GitHub Desktop.
Time scale independent Particle system in unity3d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
when TimeScale set to 0 simulate not working in my project i don't know whats wong
Thanks, This help me much!!!
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
Now you can use ParticleSystem.playbackspeed instead
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
void Update ()
{
particle.Simulate(Time.unscaledDeltaTime, true, false)
}