Page 1 of 1

particles

PostPosted: Tue Oct 05, 2010 7:11 am
by smoothie
i have made a particle and was wondering how to make it last for 1 second and then fade away

Re: particles

PostPosted: Tue Oct 05, 2010 7:18 am
by skydereign
On the create event of the particle, set a timer for 1 second, with this code. This won't destroy the actor for you, but it is easy to implement if need be. Of course you would change the 0.01s to change the speed of fade.
Code: Select all
transp=0.01;


And in draw have this.
Code: Select all
if(transp!=0)
{
    transp+=0.01;
}

Re: particles

PostPosted: Tue Oct 05, 2010 7:20 am
by DilloDude
Use some actor variable. If you already have an actor variable that the particle isn't using (such as health), you can use that, otherwise create a new one (click the variables button in the script editor, make it an integer and set it as an actor variable). It can have any name, but in this example, we'll call it 'time'.
Then add a draw actor event to the particle, and make it a script editor action. Add this code:
Code: Select all
if (time < 30) //30 frames is one second at the standard framerate, you can adjust this number
{
    time ++; //increase time by 1
}
else //if 1 second has already passed
{
    transp += .05; //add transparency to fade out - you can adjust this number to change the fade rate

    if (transp >= 1) //if it's completely faded out
    {
        DestroyActor("Event Actor"); //destroy the particle
    }
}

You could also use a timer to change a fade variable, but this method allows you to see the script all together.

Re: particles

PostPosted: Tue Oct 05, 2010 7:50 am
by smoothie
awesome thank you for your replys and sorry for terible spelling