What's happening on UAT's campus- A blog published by UAT Students.

Unity Particle Systems

    This was actually based off of a video that I found recently, and one that can be viewed here:

    http://www.unity3dstudent.com/2010/10/beginner-b23-particle-systems/

    Regardless though, it's a fun video and I've provided a write up of the information to make things a little bit easier.  I hope this helps you build a game in the future!

    One of the ways that you can really give some of your actions in a game some impact is by adding a particle effect.  One of the things Unity allows us to do is to create simple particle effects that can be called through code, and altered with a variety of preset settings.  So to get started what you need to do first is in your scene, go to GameObject, Create Other, and then Particle System.  In the particle system itself you can then find a large number of settings that if you haven't seen before might feel a little bit intimidating.  That's OK though, since you don't necessarily need alter all of them before getting underway.  Instead there's a few key ones that we're going to look at: Min/Max Size, Min/Max Energy, Min/Max Emission, Tangent Velocity, One Shot, Autodestruct, Color and Material.

    Min/Max Size: Affects the size of the particle, and the system itself generates a random value between the two values you set.  So this way you can have some very small particles, medium, and large all mixed together to create something more convincing!

    Min/Max Energy: How long the particles last in the scene.  Once again between the two values that you set each individual particle is set a random time in which it will fade out.  Particles shouldn't last overly long, nor should they flicker out in a fraction of a second or they'll lose their impact so be mindful with these settings.

    Min/Max Emissions: How many particles spawn.  One again you set two values and the number will be a random value between the two numbers.

    Tangent Velocity:  This affects the spread of the particles.  So do you want them to stay clumped as they might be for a fire?  Or do you want them to shoot in every direction like an explosion?  Altering these will allow you to decide.  At 0 everything is in roughly the same place, while anything above zero is the number of units the particle is moving in the world per second.

    One Shot: How long does the particle last.  Once again this is the difference between a fire and an explosion.  This is just a boolean value (check box) so if you want the effect to just go off once then check this box.  Do not get this confused though with Autodestruct.  All "One Shot" means is that the effect will only run through its cycle once and not allow more cycles to start until the first one is completely finished.

    Autodestruct:  Whether or not the Particle System destroys itself after running.  So this needs to be used in conjunction with the "One Shot" value I mentioned before otherwise the effect does loop.  After the Particle System destroys itself then it won't continue to run.

    Color:  This component has two things: Color and transparency.  If you click on any of the boxes it will open up a color menu with your normal RGB channels, as well as an Alpha channel.  Color is pretty self-explanatory as it allows you to change the overall color of the particle emitted.  The Alpha though affects how transparent the object is.  By default the particles go through 5 stages from barely visible, to visible, back to barely visible until they actually vanish.

    Material: What material you want to put on the particle and the way your particle will look.  By default this is a colorless orb that is then granted color by the "Color" system previously mentioned.  But you can create your own material and add it here to make the particle look more how you want it too.  If you want to add a material and have it appear as it pictured then simply leave the color of the "Color" system as white.  For the example in the video, the gentleman uses a simple star with a transparent background png that he made in Photoshop.  Then he made a Material (Project Folder -> Create -> New Material) and then added the Star to it to create a new Star Material.  Then simply replace the "Default Material" found in the Particle System with this new one to get the desired effect.

    Once the system is added to your scene and you have all your settings the way you like. It would then be advisable to make this new particle system a prefab so you can use it as many times as you would like.  Now when you're working with your code you can create a new public variable of type "ParticleSystem" and assign the prefab to it.  This object can now be instantiated using the Instantiate() function in code.  For instance, when we were doing the 2D projects before we were required to use the Destroy() and it was just a very simple script we could add to any object.  Now we can add the Instantiate() of the Particle System just before the destruction so that it will create a particle when the object is destroyed.

    It's a fun little system, that's pretty easy to use once you understand the basics!

    Posted on Mar 23, 2016 5:05:29 PM by admin in Blogs, in tutorial, in code, in Particles, in Unity

    admin

    Written by admin

       

    Email me when there is a new post.

    I'd like more information about UAT

    Lists by Topic

    see all

    Posts by Topic

    see all