unity 3d student

Beginner B23 – Particle Systems

Creating a simple explosion using a particle system instantiated from a prefab.

Code Used (Javascript)

var stars : ParticleEmitter;
  1.  
  2. function OnCollisionEnter (col : Collision) {
  3.  Instantiate(stars, transform.position, transform.rotation);
  4.  Destroy(gameObject);
  5. }

Further Reading

Share via Social Media

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Add to favorites

31 Comments

    […] Source: Beginner B23 – Particle Systems (Unity3DStudent.com) […]

  • […] Referência: Beginner B23 – Particle Systems (Unity3DStudent.com) […]

    • Hi,
      I’m using the new Unity 4, and the particle system properties are different there.
      What should i do ?
      Thanks in advance.

    Hi,

    I cant seem to get this to work. I get an error explaining
    “UnassignedReferenceException: The variable Explode of ‘WallCollide’ has not been assigned.
    You probably need to assign the Explode variable of the WallCollide script in the inspector.”

    However, I have definitely placed my explosion particle emitter into the script used in the Wall instance…

    var Explode : ParticleEmitter;
    function OnCollisionEnter (collide : Collision) {

    if(collide.gameObject.name == “Shot(Clone)”) {
    Debug.Log(“HIT!”);
    Instantiate(Explode, transform.position, transform.rotation);
    Destroy(gameObject);
    }

    }

    (the Shot(Clone) part is just me being lazy a bit.. never mind that haha)

    So it hits, for sure, but I always get this error, no matter what I do. Ive spent 2 hours trying to fix it.

    • It’s one of 2 things, either you have assigned your particle prefab to the variable slot in the inspector having selected the script in the project panel and forgotten to actually assigned it to the script when it’s attached to your gameobject or prefab object OR it could be a bug in unity – best thing to do about the latter is remove the script as a component of your object or prefab and then reattach it and then reassign the particle prefab to it.

    I just typed up the boxDestroy script. How do I put it onto the object? As itself, it won’t let me save as a script, like the Timed Object Destructor itself. What I’ve done is made another TOD and did Edit Script, and wrote it there. The script works, but now I wonder would the original TOD affect the whole thing to any degree?

    • If you were unable to write a script and attach it to an object then there is either a problem with your unity install or you’re making a mistake..

    As always, great tutorial! Do you think, if you have time of course, you could do a more advanced particle system tutorial, to show how you would make things like clouds, smoke, fire, etc? (Things that would be a little more complex than emitting a bunch of star textures)

  • Really enjoying these tutorials Will. This one was fantastic.

  • […] サイトの見方がよくわからないですが、 試しにParticleについての章をやってましたが、動画を見れば英語はわからないくて理解できます。 […]

  • Chuta los locos, aki se habla de too parece kjokj que pesaooh Nice tutorial.

  • Great tutorials, don’t know where I’d be without them! I’m having a problem trying to do this one though. When I create a material, it doesn’t have the options in the inspector i.e. I can’t drag and drop my image to texture the material. All the other options are also gone, all I can get is the drop down to select what type of shader (?). Even after the selecting the different types of shaders, the area still remains blank.

    Is this something that you can only access with the full version of Unity?

  • Sorry about that, I’ve got it now. It seemed to be a bug because I went down the list of shaders and it suddenly appeared for all of them :p Wierd.

  • You’ve explained everything well except how you’ve created your weight and weight prefab. This is crucial as there isn’t anywhere to attach the script to without knowing how you did this and what they are for.

    Please could you explain? :o)

  • This tutorial was one of the funnest so far, always loved playing around with particleFX. Great job WG

  • Thanks for explanation!

  • Hey man awesome tutorials here. They are extremely easy to follow and help a lot to understand what I’m looking at when I open up Unity. I really appreciate all the time and effort you’re putting in to spreading the knowledge. I do have a few questions regarding the new particle system in Unity though.

    This tutorial is a little outdated. The new particle system in Unity doesn’t have an auto destruct check box. Would I just write an object destroy script and attach it to the particle system? If I wanted multiple instances of the same non looping particle system, would i just create a few of them on start and move them around and play them as needed? How would I go about doing that?

    Sorry for being such a noob here, but this has stumped me.

  • Amazing tutorials. Thank you so much, as someone who mostly just makes assets i’ve been trying to find a fun way to ease into learning scripting to better understand what goes on, and communicate with game developers , and this has been really helpful.

    Every video has been pretty much still vary relevant even now, until this one.

    I currently have Unity 3.5.4, and the particle system is a bit different than the one in this video.
    So i’m just adding some notes of the changes I had to figure out for the next person like me.

    “SET MIN/MAX SIZE”
    – Particle System
    – Start Size
    – “Random Between Two Constants
    1, 3
    “NEW SET ENERGY”
    – Particle System
    – Start Lifetime
    – “Random Between Two Constants
    1,2
    “NEW ADD BURST”
    – Emission
    – Rate
    0
    – Add Bursts
    Time 0, Particles 30
    “NEW TANGENT VELOCITY”
    – Shape
    – Sphere

    “NEW AUTO DESTRUCT”
    – Particle System
    – UnCheck Looping

    Also I was unable to add the prefab, and had to change the script from ParticleEmitter;, to GameObject; as you mentioned you could do in the video.

  • Okay, I ran into some trouble following along on this. The key was distinguishing between a ParticleEmitter and a ParticleSystem, which I think was added after this tutorial.

  • can you do this tutorial again on the new particle system engine?

  • There isn’t a one shot for me… there is a bunch of grid sort of things in the inspector.

  • Nice one! Funny! I noticed you didn’t mentioned how to kill particle system.
    Here is the link: http://blog.i-evaluation.com/2013/02/17/auto-destroying-particle-system-in-unity3d/

  • In your example, the particle emitter shoots the particles in all directions because you applied the tangent velocity. When you run, the particles go into the floor. How do you make the particles only shoot up in all directions (ie a hemisphere above the floor)?

  • I thought this might help for the new comers.

    “Unity’s particle system was written from scratch in version 3.5, the new one is ParticleSystem.

    ParticleEmitter belongs to the old particle system, you shouldn’t need it unless you’re working on a project you started before 3.5. “

  • Hi there,
    I am using Unity 4 and the particle FX is completely different than in the video… also is there a free editing program that can save to a file format that Unity can read? I used Paint.net and can create an object with no background but it isn’t able to be ready by unity….

  • Its Good.

  • Can anyone please tell me how to translate (move) a particle system that was created on a prefab? The normal translate tools are not moving. I want to move my particle system a little to the left (x axis)…..Please advise. Thanks a lot for any help.

  • the normal translate tools are not WORKING i mean…sorry for the typo. >_>

  • I really like your tutorials, this in particular was pretty attractive to me because i’m specially interested into learning how to create customized explosion effects.

    Thanks.

  • […] Beginner b23 – particle systems – unity 3d video Learn video game development with unity game engine the easy way!. […]

  • […] Unity 3d video tutorials | 100% free | beginner b23 Hey man awesome tutorials here. they are extremely easy to follow and help a lot to understand what i’m looking at when i open up unity. i really appreciate all the. […]

Leave a Comment