Making particle effects in Unity

Posted on

in

,

In this example I’m making a lightning attack effect. The lightning image gets bigger as it reaches it’s target and the movement will be controlled via code.

Make a new particle system by right clicking the hierarchy and selecting ‘Particle System’. Drag the sprite you want to use into that object. You may have to change the shader in the Inspector to get your sprite’s transparency looking right. ‘Particles/Alpha Blended’ works for me.

Now’s the time to tweak your particle. Single tapping the darker grey areas will expand/collapse them. The first ‘tab’ has all the options you’d expect like duration/looping/start size etc. Play around with the settings.

For my particle I used ‘Simulation Space: World,Start Speed:100,Emission Rate: 700, Time, Shape: Cone with 0 angle and 0.01 Radius and Size over Lifetime:0 to 100 in a straight line’.

When you’re happy with it, turn it into a prefab as you’ll likely be reusing it and then add to your game via code the same way as a prefab.

Remove your particles after they’ve finished automatically by putting this in the Start() function:

if(gameObject.GetComponent<ParticleSystem>())
        {
            GameObject.Destroy(gameObjectgameObject.GetComponent<ParticleSystem>().duration + gameObject.GetComponent<ParticleSystem>().startLifetime);
        }

 

Leave a Reply

Your email address will not be published. Required fields are marked *

About me

Mark Wong is a front end developer with 10+ years experience. Most of his knowledge of HTML5, CSS and Js is self taught.

Calendar

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031