![]() |
|
Basics So now comes the fun part, improving the looks of our effect. You
have probably noticed, that the particles are deleted fitfully when they
reach the age of 40. It would be much nicer to fade them out smoothly. So we can fade out our particles easily, if we set the my_alpha attribute depending on the particle age. We just have to make sure, that my_alpha has a very low value (near 0) when the particle reaches it's terminal age. In our case, we can achieve this effect very easily if we start the
fadeout effect at an age of 20. Instead of setting the my_alpha value and really decreasing it by five each frame, we can also use a formula for the fadeout. This makes it easier to change the duration of the fadeout later on. Here is the according formula: my_alpha = 100 - (my_age - 20) * 5; We just have to pack it into an if-query, that checks if the particle has already reached the age of 20:
if (my_age > 19) { Insert these lines into our function and test what happens! You should notice a big difference. The modified files can be found in the Tutorial_templates directory. They are named tut2.wdl and tut2.wmp. |