particles

Game Editor comments and discussion.

particles

Postby smoothie » Tue Oct 05, 2010 7:11 am

i have made a particle and was wondering how to make it last for 1 second and then fade away
User avatar
smoothie
 
Posts: 32
Joined: Sat Oct 02, 2010 11:51 am
Score: 0 Give a positive score

Re: particles

Postby skydereign » Tue Oct 05, 2010 7:18 am

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;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: particles

Postby DilloDude » Tue Oct 05, 2010 7:20 am

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: particles

Postby smoothie » Tue Oct 05, 2010 7:50 am

awesome thank you for your replys and sorry for terible spelling
User avatar
smoothie
 
Posts: 32
Joined: Sat Oct 02, 2010 11:51 am
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron