• 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 "min$$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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Cannot Change emission.rate 3 Answers

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

ParticleSystem emission rate is incomprehensible. 0 Answers

emission is not a member of UnityEngine.ParticleSystem? 0 Answers

Particle System throws IsFinite and AABB 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges