- Home /
The question hasn't any answers and doesn't make any sense.
Dynamic Particle System Lifetime??
I Have Tried Changing Lifetime Of A Particle System Dynamically Via Script, But It Seems Like Unity3D Doesn't Have A Way Or A Function To Do This, So I Have Tried 2 Ways, Which I Have Expected ParticleSystem.main.startLifetime Doesn't Work Before Testing It:
main.startLifetime = 2.5f;
And:
particle.time = main.startLifetime.constant * 0.8f;
Both Of Them Won't Work, So Is There A Way To Do That?
Thanks..
Answer by Komayo · Aug 19, 2017 at 03:19 PM
particleSystem.startLifetime = 1.2f; // 1.2 seconds
I Have Gave The Same Script Above And Said That It Won't Work, But You Gave $$anonymous$$e The Same Thing :D , startLifetime Isn't Dynamic, It Only Affects The Particle System When It Plays Or Emits, Not During The Lifetime! What I Want Is The Particle System Gets Instantiated And When An (if) Statement Returns True, I Want The Particle System To Reduce Its Lifetime! Not To Wait Its Original startLifetime Parameter Until The Particle Fades Out!
But Anyway.. Thanks :)
Answer by ifurkend · Aug 19, 2017 at 05:25 PM
To access the "remainingLifetime" of particles, you need to getParticles, modify each particle in the loop then setParticles. Simply follow the code example in the doc: https://docs.unity3d.com/ScriptReference/ParticleSystem.GetParticles.html
No I Don't Want To Access Remaining Lifetime, I Want To To Change The Lifetime During The Emit Of The Particle, For Example:
The Particle System By Default In The Prefab Has 20 Seconds StartLifetime, And After Getting Instantiated, Let's Say I Have A Button, And When I Press It, I Want To Reduce The Lifetime Of The Particle System, So Let's Say 10 Seconds Passed, Then I Pressed The Button, So I Want To $$anonymous$$ake The $$anonymous$$aximum Lifetime Of The Particle 12.5 Or 15 Seconds Ins$$anonymous$$d Of The Original 20 Seconds When Gets Instantiated!