1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    Dismiss Notice

How to play a shuriken particle system?

Discussion in 'Scripting' started by Tiles, Jun 26, 2012.

  1. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Messages:
    2,460
    I have this code here. With the old particle system i had no problem to play it with the old keywords ParticleEmitter instead ParticleSystem and emit instead play.

    Code (csharp):
    1. var myparticlesystem: ParticleSystem;
    2. var test:boolean=false;
    3.  
    4. function OnCollisionEnter(other: Collision){
    5.         test=true;
    6.         myparticlesystem.play=true;
    7. }
    The particle system is in the variable slot. Test goes to true with a collision. The collision triggers. But the particle system does not play. I get an error instead:

    Code (csharp):
    1. MissingFieldException: Field 'UnityEngine.ParticleSystem.play' not found.
    The reference says that i have to use Play though (by the way, why is the first letter big here? Shouldn`t it be a small letter?)

    http://unity3d.com/support/documentation/ScriptReference/ParticleSystem.Play.html

    What is wrong here?
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Messages:
    5,669
    Play is a method, not a property or a field.

    Code (csharp):
    1. myparticlesystem.Play();
     
  3. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Messages:
    2,460
    Ah, no wonder. So the method has changed too, not just the keywords. Many thanks Dantus :)

    I wish this would be mentioned in the manual too ...
     
  4. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Messages:
    1,217
    Typical case of RTFM: Particle System. The docs already describes all of the methods the class has.

    Edit:
    P.S.

    ParticleAnimator, ParticleEmiter and ParticleRenderer are part of the legacy (old) Particle system.

    ParticleSystem, ParticleSystem.Particle and ParticleSystemRenderer are the new Shuriken Particle classes
     
    Last edited: Jun 27, 2012
  5. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Messages:
    2,460
    This was and is always my first way. But this didn`t help me, as usual. I nearly always end in the forum when i have a look at the reference. Because it is more a dictionary. And doesn`t really help with the useage in most cases.

    I was in need of Dantus`s code snippet to understand what is meant. And then i understood it very quick. So again thanks Dantus.
     
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Messages:
    5,669
    You can see it in the documentation that you are dealing with a function (method). The line just below the title is:

    I struggle with this kind of things too if I have to implement something in UnityScript, as it doesn't (or maybe didn't?) have such good autocompletion as C#.

    @Tseng: You can not tell someone RTFM, if he even posted a link to it :).
     
  7. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Messages:
    2,460
    Yes, but i didn`t realize it until i saw your code snippet. I was too focused at the old method with the flag. My brain refused to accept what it has read. Maybe i should have a look for a new brain. Do you have one left? :)