- Home /
How to emit particle or un-pause particle when timescale =0?
How to emit particle or un-pause particle when timescale =0? My particle i have now runs great when timescale is = 1 but when it is = to 0 it is paused? how can i keep the particle playing even when timescale is = to 0?
Answer by Negagames · Apr 27, 2013 at 07:21 PM
When you set the timescale to 0, everything on the scene is paused. No, you cannot run a particle system when the timescale is at zero.
The wrong answer. For the best way, find the answer to @$$anonymous$$ikina. The same technique is used in my RPG game.
Answer by kk93 · Feb 19, 2014 at 11:36 PM
I know this is an old post, but the above answer is incorrect.
Just attach this script to the particle system you wish to ignore Time.timeScale:
Answer by Mikina · Dec 15, 2018 at 03:36 PM
For anyone who stumbles upon the question now:
There is a Delta Time property on Particle Systems, that can be set to Unscaled, which will cause the ParticleSystem to be independent of TimeScale.
This is the answer. After a long search, I integrated this technique in my RPG game. It's working fine. No need of adding any additional script.
Answer by seantheyahn · May 30, 2015 at 11:29 AM
Just attach this script to the GameObject with your particle system:
using UnityEngine;
using System.Collections;
public class UnscaledTimeParticle : MonoBehaviour
{
// Update is called once per frame
void Update()
{
if (Time.timeScale < 0.01f)
{
particleSystem.Simulate(Time.unscaledDeltaTime, true, false);
}
}
}
Firstly, this code has been very helpful, so thanks for that! However, my looping particle effects wouldn't 'un-pause' when Time.timeScale became 1 after being 0.
So I did this to fix my issue:
void Update()
{
if (GetComponent<ParticleSystem>().main.loop == false)
{
if (Time.timeScale < 0.01f)
{
GetComponent<ParticleSystem>().Simulate(Time.unscaledDeltaTime, true, false);
}
}
else if (GetComponent<ParticleSystem>().main.loop == true)
{
if (Time.timeScale < 0.01f)
{
GetComponent<ParticleSystem>().Simulate(Time.unscaledDeltaTime, true, false);
}
if (Time.timeScale > 0.01f)
{
GetComponent<ParticleSystem>().Simulate(Time.unscaledDeltaTime, true, false);
}
}
}
I hope that helps anyone who faced a similar issue to myself. If someone else finds a cleaner way to write this code, however, please don't hesitate to edit this... umm... edit. Thanks!