Can I change particle lifetime on the fly and see results in real time via the particles?

wayback_gamerwayback_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

  • SocksSocks London, UK.Posts: 12,822
    edited October 2015 Accepted Answer

    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

  • SLOCM3ZSLOCM3Z Member Posts: 797

    Is there an e for expression editor in the lifetime attribute of the particle?

  • wayback_gamerwayback_gamer USMember, PRO Posts: 124

    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

  • wayback_gamerwayback_gamer USMember, PRO Posts: 124

    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.

  • SLOCM3ZSLOCM3Z Member Posts: 797

    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

  • wayback_gamerwayback_gamer USMember, PRO Posts: 124

    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

  • SLOCM3ZSLOCM3Z Member Posts: 797

    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?

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    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.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @wayback_gamer said:
    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 do not affect performance ugh... I use them all the time. What the issue is sloppy bloated code.

  • wayback_gamerwayback_gamer USMember, PRO Posts: 124

    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!

Sign In or Register to comment.