• 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 /
avatar image
0
Question by neonwarge04 · Feb 05, 2016 at 04:07 PM · c#particlesystem

Changing particle emission rate via C# script

Unity deprecated a lot of methods and properties in setting up a decent effects for my game. I need to change the rate of particle emission. How am I suppose to do t$$anonymous$$s?

emission.emissionRate is deprecated stop suggesting it.

Comment
Add comment · Show 1
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 melkorinos · Feb 05, 2016 at 04:36 PM 0
Share

Tried this one ? emission.rate (float)

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Helical · Oct 23, 2016 at 02:18 PM

         //does NOT work
         //system.emission.rate = Random.Range (emmisionRateMin, emmisionRateMax);
 
         //works
         var em = system.emission;
         em.rate = Random.Range(emmisionRateMin, emmisionRateMax);
Comment
Add comment · Show 3 · 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 amzin7000 · Nov 12, 2016 at 08:52 PM 0
Share

Thanks, worked like a charm!

avatar image Antypodish · Jun 29, 2017 at 02:27 PM 0
Share

'rate' is obsolete in 2017 beta

avatar image Mehrdad995 Antypodish · Oct 10, 2017 at 08:06 PM 1
Share

use rateOverTime or rateOverDistance instead.

avatar image
2

Answer by Halfbiscuit · Feb 06, 2016 at 11:28 AM

It seems to be rather more complex to do t$$anonymous$$s now but you can access the ParticleSystems emission variable then set the emission.rate.mode to ParticleSystemCurveMode.Constant.

After that setting either the emission.rate.constantMax or emission.rate.constantMin should allow you to set the emission rate.

Comment
Add comment · Show 2 · 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 dmurtha · Oct 13, 2016 at 12:59 AM 0
Share

Could you perhaps go into more detail as to how to do this? This is my code: private Vector3 lastPosition; private bool mouseWasDown = false; private ParticleSystem particleObjects;

     private float min = 37.0f;
     private float max = 45.0f;
     private float dif = 8;
     private float mag = 37.0f;
     private float val;
     private float floor = 120.0f;
     private float ceiling = 1000.0f;
     private float room = 880.0f;
     void Start ()
     {
         dif = max - min;
         room = ceiling - floor;
         particleObjects = GetComponent<ParticleSystem> ();
         var em = particleObjects.emission.rate;
         em.mode = ParticleSystemCurveMode.Constant;
     }
     void Update () 
     {
         if (Input.GetMouseButton (0)) {
             if (mouseWasDown == false) {
                 lastPosition = Input.mousePosition;
                 mouseWasDown = true;
                 return;
             }
             Vector3 mouseDelta = Input.mousePosition - lastPosition;
             mag = (Mathf.Clamp (mouseDelta.magnitude, floor, ceiling) - floor) / room;
             val = mag * dif + min;
             var em = particleObjects.emission.rate;
             em.constantMax = val;
             em.constantMin = val;
         } else {
             mouseWasDown = false;
         }
     }

Where am I going wrong?

avatar image Mehrdad995 · Oct 10, 2017 at 08:05 PM 0
Share

or just keep it as curve instead of constant and create a curve for yourself (ParticleSystem.MinMaxCurve), then change the rate from min up to max by evaluate.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to render a particle system with a preset particle system in a prefab? 0 Answers

How to Pause ParticleSystem on Jump? 2 Answers

How to change the mesh of a particle system at runtime C# 2 Answers


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