Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Particle System vs Particle Emitter.

Discussion in 'Scripting' started by BFDesign, Apr 24, 2012.

  1. BFDesign

    BFDesign

    Joined:
    Mar 16, 2011
    Posts:
    214
    I have a particle system in my scene that I am trying to disable when a GUIButton is activated.
    I set up something like this within my function:
    Code (csharp):
    1.  
    2. var particleEmitter : ParticleEmitter;
    3.  
    4. if (GUI.Button (Rect (a,b,c,d), "Summer")) {
    5.         ToggleRenderersWithTag("Summer");
    6.        
    7.         particleEmitterObject.particleEmitter.emit = !particleEmitterObject.particleEmitter.emit;}
    But the particle system stays enabled the whole time. Is there a difference between a "particle System" and a "Particle Emitter"?


    Thanks.
     
  2. dodo

    dodo

    Joined:
    Jul 13, 2011
    Posts:
    49
    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.
     
  3. BFDesign

    BFDesign

    Joined:
    Mar 16, 2011
    Posts:
    214
    So would I just call ParticleSystem instead of ParticleEmitter?
     
  4. dodo

    dodo

    Joined:
    Jul 13, 2011
    Posts:
    49
    Yep, create a ParticleSystem in your scene and hold the reference to that particle system in your script.

    Also note that the new particle system does not have "emit" property, instead it has Play and Stop functions.
     
  5. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    Either that or you need particle collisions, than one must use the old system too. Because Shuriken doesn't support particle collisions yet (hope it gets added in 3.6, as it's the only way which prevents me from using it at the moment)
     
  6. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    There is actually a big difference between the two. ParticleEmitter's are well documented and can even be created from within code. ParticleSystems are more complicated, less documented and cannot as of yet be fully created through code. This said, they are probably easier to control through code than ParticleEmitters on a per particle aspect.

    I used the concept of the procedural effects to create a streaming particle bridge between two points. Worked perfectly when you can control particle groups. This is very easily done in ParticleSystems.
     
  7. zastrow

    zastrow

    Joined:
    May 23, 2012
    Posts:
    20
    So how would you rewrite JetPackParticleController.js in the 3DPlatformTutorial to be compatible with the current particle system and not the old particle emitter?

    Code (csharp):
    1.  
    2. private var litAmount = 0.00;
    3.  
    4. function Start () {
    5.  
    6.     var playerController : ThirdPersonController = GetComponent(ThirdPersonController);
    7.    
    8.     // The script ensures an AudioSource component is always attached.
    9.    
    10.     // First, we make sure the AudioSource component is initialized correctly:
    11.     audio.loop = false;
    12.     audio.Stop();
    13.    
    14.    
    15.     // Init the particles to not emit and switch off the spotlights:
    16.     var particles : Component[] = GetComponentsInChildren(ParticleEmitter);
    17.     var childLight : Light = GetComponentInChildren(Light);
    18.    
    19.     for (var p : ParticleEmitter in particles)
    20.     {
    21.         p.emit = false;
    22.     }
    23.     childLight.enabled = false;
    24.  
    25.     // Once every frame  update particle emission and lights
    26.     while (true)
    27.     {
    28.         var isFlying = playerController.IsJumping();
    29.                
    30.         // handle thruster sound effect
    31.         if (isFlying)
    32.         {
    33.             if (!audio.isPlaying)
    34.             {
    35.                 audio.Play();
    36.             }
    37.         }
    38.         else
    39.         {
    40.             audio.Stop();
    41.         }
    42.        
    43.        
    44.         for (var p : ParticleEmitter in particles)
    45.         {
    46.             p.emit = isFlying;
    47.         }
    48.        
    49.         if(isFlying)
    50.             litAmount = Mathf.Clamp01(litAmount + Time.deltaTime * 2);
    51.         else
    52.             litAmount = Mathf.Clamp01(litAmount - Time.deltaTime * 2);
    53.         childLight.enabled = isFlying;
    54.         childLight.intensity = litAmount;
    55.                    
    56.         yield;
    57.     }
    58. }
    59.  
    60. @script RequireComponent(AudioSource)
     
  8. Tatsuyame

    Tatsuyame

    Joined:
    May 28, 2012
    Posts:
    1
    I just started the tutorial and ran into this same issue. Here are the changes I made to the code that got it to work:
    Code (csharp):
    1.  
    2.  
    3. private var litAmount = 0.00;
    4.  
    5. function Start () {
    6.  
    7.     var playerController : ThirdPersonController = GetComponent(ThirdPersonController);
    8.    
    9.     // The script ensures an AudioSource component is always attached.
    10.    
    11.     // First, we make sure the AudioSource component is initialized correctly:
    12.     audio.loop = false;
    13.     audio.Stop();
    14.    
    15.    
    16.     // Init the particles to not emit and switch off the spotlights:
    17.     var particles : Component[] = GetComponentsInChildren(ParticleSystem);
    18.     var childLight : Light = GetComponentInChildren(Light);
    19.    
    20.     childLight.enabled = false;
    21.  
    22.     // Once every frame  update particle emission and lights
    23.     while (true)
    24.     {
    25.         var isFlying = playerController.IsJumping();
    26.                
    27.         // handle thruster sound effect
    28.         if (isFlying)
    29.         {
    30.             if (!audio.isPlaying)
    31.             {
    32.                 audio.Play();
    33.             }
    34.         }
    35.         else
    36.         {
    37.             audio.Stop();
    38.         }
    39.        
    40.        
    41.         for (var p : ParticleSystem in particles)
    42.         {
    43.             if(isFlying)
    44.                 p.Play();
    45.             else
    46.                 p.Stop();
    47.         }
    48.        
    49.         if(isFlying)
    50.             litAmount = Mathf.Clamp01(litAmount + Time.deltaTime * 2);
    51.         else
    52.             litAmount = Mathf.Clamp01(litAmount - Time.deltaTime * 2);
    53.         childLight.enabled = isFlying;
    54.         childLight.intensity = litAmount;
    55.                    
    56.         yield;
    57.     }
    58. }
    59.  
    60. @script RequireComponent(AudioSource)
    61.  
    Note: I had to enable prewarm on the particle systems before it would work.
     
  9. zastrow

    zastrow

    Joined:
    May 23, 2012
    Posts:
    20
    I'll check it out. Kinda crazy Unity has this on their website as a current tutorial when it's not compatible with the current version of Unity3D.
     
  10. deepcover

    deepcover

    Joined:
    Mar 13, 2009
    Posts:
    14
    @Tatsuyame This helped me. Thank you.