Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by robdil · Jan 31, 2016 at 02:47 AM · particlesparticlesystem

Unity 5: turning particles on/off

Hi,

I checked for this problem in the archive but all answers I could find date back to 3 or 4 years ago and are clearly obsolete. I am using Play() and Stop() to achieve this but the result is really strange. This is what I am doing:

I want the particle system to be off when the scene starts so in Start() I have:

     pSystem = this.GetComponent<ParticleSystem>();
     pSystem.Stop ();  

Then when the player presses Fire1 particles should be activated and should be stopped again when Fire1 button is released. In Update() I wrote this:

     if (Input.GetButtonDown ("Fire1"))
         pSystem.Play ();

     if (Input.GetButtonUp ("Fire1"))
         pSystem.Stop ();

What happens is that it works but only once: after particles have been turned on and off once, pSystem.Play() doesn't have any visible effect any more even though it is called again when Fire1 is pressed.

Any idea of what could cause this? Thanks in advance!

Comment
Add comment
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 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by FrigginTommyNoble · Feb 28, 2016 at 01:21 AM

Hey @robdil, so I had the same issue. After much trial and error, it looks like the combination of Play() and enableEmission is what works. Here's a simplified thruster script attached to a particle system, seems like it would apply to your use case.

 using UnityEngine;
 using System.Collections;
 
 public class ThrusterController : MonoBehaviour {
     private ParticleSystem ps;
 
     void Start()
     {
         ps = GetComponent<ParticleSystem>();
         PlayThrusters();
     }
 
     void Update()
     {
         // Thrust button pressed, start particle system
         if (Input.GetButtonDown("Thrust Forward"))
         {
             PlayThrusters();
         } 

         // Thrust button released, deactivate particle system
         if (Input.GetButtonUp("Thrust Forward"))
         {
             StopThrusters();
         }
     }

     void PlayThrusters()
     {
         ps.Play();
         ps.enableEmission = false;
     }

     void StopThrusters()
     {
         ps.enableEmission = false;
         ps.Stop();
     }
 }
 

Hope that helps.

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 carlilelance · Sep 26, 2018 at 10:33 PM 0
Share

line 30 has a small bug. it should say ps. enableEmission = true; (not false).

unity flags enableEmission as obsolete and the replacement attribute "emmision.enabled" seems to be readonly. so what gives? why do you have to use enableEmission to make it work as expected. thanks for the solution friggintommynoble, but it would be nice if we understood the whys behind it.

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

44 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 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

How would you make a dust trail with a 2d sprite animation? 0 Answers

Particle System Instantiate wrong transform, position on Rig Builder / ragdoll conflict 0 Answers

Particles syncing on the Unity Network 4 Answers

I have a particle system that is playing at the wrong time... 1 Answer

Having Player light torches Using Particle System and OnCollisionEnter? 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