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 AleksanderN · Jun 02, 2017 at 04:14 PM · particlesystememissionrate

How to set particle emission rate at run time?

ParticleSystem p; p.emission.rateOverTime = 20f;

Keep on telling me that I can't do that, tried other solutions like: ParticleSystem p; var em = p.emission; em.rateOverTime = 20f; p.emission = em;

Does not work either. How do you change particle rate over time during run time?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by ifurkend · Jun 02, 2017 at 09:52 PM

https://blogs.unity3d.com/2016/04/20/particle-system-modules-faq/

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 Sayama · May 26, 2020 at 05:57 AM

Well, I'm a bit late (3 years) BUT, because I was in the situation, I have a solution! Basically, you have to manually emit the number of particle you want and disable the particle generation beforehand.
(Rate over Time = 0)

In my example, I want to set the number of particles according to my speed :


 using UnityEngine;
 
 public class ExempleParticuleSetter : MonoBehaviour
 {
     private ParticleSystem particleSystem;
     //In my exemple, x = min & y = max
     [SerializeField] private Vector2 minMaxEmmiter = new Vector2(0,80);
     [SerializeField] private Vector2 minMaxSpeedDesire = new Vector2(80,200);
 
     //Other variable I need
     private Rigidbody rb;
 
     private void Start()
     {
         particleSystem = GetComponentInChildren<ParticleSystem>();
         
         rb = GetComponent<Rigidbody>();
     }
 
     private void Update()
     {
         //Get the number of particle to emit by some little calculation
         var speed = rb.velocity.magnitude;
         var t = (speed - minMaxSpeedDesire.x) / (minMaxSpeedDesire.y);
         var particleToEmit = (int) Mathf.Lerp(minMaxEmmiter.x, minMaxEmmiter.y, t);

         //Here I Emit my particle
         particleSystem.Emit(particleToEmit);
     }
 }

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 shieldgenerator7 · May 28, 2020 at 06:36 PM 0
Share

how does it know when not to emit a particle?

avatar image Sayama shieldgenerator7 · May 28, 2020 at 07:10 PM 0
Share

In this example, when the speed is below "$$anonymous$$$$anonymous$$axSpeedDesire.x" is equal to 0 and so, the Lerp function will set the number of particle "particleToEmit" (I could have set a better name) to 0, and so, no emission.

But in other type of script, you can put a public Boolean et toggle it within other scripts. this way, the last particle will die and don't emit, like this :

 if (urBoolean)
 {
     particleSystem.Emit(particleToEmit);
 }

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

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

change emission rate of particles in update -> Unity 5.3 0 Answers

ParticleSystem emission rate is incomprehensible. 0 Answers

Cannot Change emission.rate 3 Answers

Low particle emission rate 1 Answer

Enabling particle system with trigger 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