Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
8
Question by PTerto · Oct 08, 2013 at 06:28 PM · c#particlesparticlesystememission

How Play and Stop a ParticleSystem through Scripting?

Hey guys, I'm trying turn on/off a simple particle emission, when i'm using Play()/Pause() ...works fine(but particles many remains there paused), and what I want to do is when the I pause the emission, the game object stop generating particles and that particles already generated finish their cycles, like the Stop()...but when I use Play()/Stop(), the emission never starts...what should I do...? Here is my simple code: using UnityEngine; using System.Collections;

 public class Test : MonoBehaviour {
     
     public bool x;
     public ParticleSystem dust;
     
     void Start () {
     
     }
     
     
     void Update () 
     {
         if(x){
             
             dust.Play();
         }
     
         else if(!x){
             
             dust.Stop();
             
             //dust.Pause();
             //dust.Clear();
         }
     }
 }
 
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Oct 08, 2013 at 10:23 PM 0
Share

Where are you modifying 'x'?

avatar image clunk47 · Oct 21, 2013 at 02:32 AM 0
Share

Has your issue been resolved?

9 Replies

· Add your reply
  • Sort: 
avatar image
13

Answer by clunk47 · Oct 08, 2013 at 10:09 PM

Simply change ParticleSystem.enableEmission between true / false.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
6

Answer by tw1st3d · Oct 08, 2013 at 06:33 PM

Well what you have there looks like it should work, other than the fact that you're not defining the bool as true or false anywhere, so you can try this.

 public class Test : MonoBehaviour 
 {
     protected bool letPlay = true;
     
     public void Update()
     {
         if(Input.GetKeyDown(KeyCode.E))
         {
             letPlay = !letPlay;
         }
     
         if(letPlay)
         {
             if(!gameObject.particleSystem.isPlaying)
             {
                 gameObject.particleSystem.Play();
             }
         }else{
             if(gameObject.particleSystem.isPlaying)
             {
                 gameObject.particleSystem.Stop();
             }
         }
     }
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PTerto · Oct 08, 2013 at 06:42 PM 0
Share

I tried this, i thought, that the problem was the definition...and the problem remains...

avatar image
2

Answer by Kerihobo · Jan 29, 2015 at 02:43 AM

I had the same problem, it worked for me but it seems to only work if i first check .isplaying or !.isplaying first, and then inside that block i use .Play or .Stop

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by wanwanli · Feb 12, 2016 at 01:51 PM

At first I have faced the same problem, and now i have solved it! First, set Looping = true Second, set play on awake = false Finally, in your code write: void play() { ParticleSystem1.Play(); ParticleSystem1.enableEmission = true; } void stop() { ParticleSystem1.enableEmission = false; } It could work well!!!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by kayding · May 16, 2016 at 02:55 PM

I just add particleSystem.enableEmission = true right after particleSystem.Play() sentence, then it's working!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Particle Collision between particles 2 Answers

Low particle emission rate 1 Answer

How to Instantiate decals where particles from particle system hits? 1 Answer

Particle System Help. 1 Answer

C# scripting and Particle System incompatibility 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges