Can I change particle lifetime on the fly and see results in real time via the particles?
wayback_gamer
USMember, PRO Posts: 124
Im trying to use particles as a boost bar, like a health bar the boost bar will build up and I want to change the particle lifetime accordingly when the boost is building up or being used and decreased. I've tried a variety of methods and no luck. Any ideas or topics anyone? Thanks
Best Answer
-
Socks London, UK.Posts: 12,822
Changing a particle's lifetime on the fly works just fine in GameSalad, attached is a demo of a waving flag that relies completely on being able to change a particle's lifetime:
Run this, then stop it and change the particle lifetime from the current expression to a fixed number, like 1 or 2 and then see what happens !
Answers
Is there an e for expression editor in the lifetime attribute of the particle?
Yes there is a place for expression, however I can seem to constrain the particle lifetime to a real decimal converted attribute that I manipulate with a loop. No matter what I try I can change the lifetime of the particles while they are spawning. I set the lifetime to a Scene real attribute then change the attribute based on conditions and there are no results
I've also tried using attributes within the actor with conversions and a combo of both so I'm narrowing it down. I get the feeling its may have to be all done outside the actor, the converting of scene attribute to decimal which the particle lifetime is set to that is.
I was thinking you could make game.ParLifetime integer and put that in the lifetime attribute of the particle and THEN make a timer that says: every (number) change attribute game.ParLifetime :to: game.ParLifetime + 1. That way the particle is doing: for the amount game.ParLifetime is, stay alive that long. But it seems like you have already tried this
Im avoiding using timers as they affect performance. The attribute would have to be a real attribute, because the lifetime will have to be in decimals. .1 the smallest and 2 the largest number. Trying to increase the value by .1 each interval somehow and the particle block doesn't reflect the new number
Timers work fine for me. I don't know why people complain about them. I have used hundreds in my game and it work beautifully on GS Arcade. How often do you have the .1 changing?
You can adjust the particle lifetime as needed, here is a sample that picks a new particle lifetime (between .1 and 2) each time you click the mouse.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Timers do not affect performance ugh... I use them all the time. What the issue is sloppy bloated code.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Thank you everyone for replying! Glad theres people out there willing to share isight and help a stranger. After 3 weeks of developing and working out lag Ive succeeded. I already made a regular bar then put a large group of particles behind it. Its amazing. Thanks again everyone I'll share my game really soon hopefully!