• 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 xDeltax · Oct 17, 2011 at 01:49 AM · arrayparticlesemit

Make an Array of Particles emit at the same time

Here's the script:

 var BParticles: ParticleEmitter[];

 function Start () {
     for (var particles in BParticles){
         particles.emit = true;
         yield WaitForSeconds (Random.Range(5.0, 10.0));
         particles.emit = false;
     }
 }

The problem is that the particles don't emit at the same time... Any help would be appreciated

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 syclamoth · Oct 17, 2011 at 01:53 AM 1
Share

(Fixed your formatting because I hate bad formatting)

avatar image xDeltax · Oct 17, 2011 at 02:15 AM 0
Share

Thank you

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by syclamoth · Oct 17, 2011 at 01:56 AM

The problem is that you are using yield WaitForSeconds(whatev) in the middle of your for loop! What is happening here, is it is cycling through your particle systems, turning each one on one at a time (which is actually kind of more sophisticated behaviour than what you were aiming for here...)

You should rearrange it so that the WaitForSeconds bit only happens once-

 function Start () {
     for (var particles in BParticles){
         particles.emit = true;
     }
     yield WaitForSeconds (Random.Range(5.0, 10.0));
     for (var particles in BParticles){
         particles.emit = false;
     }
 }

This way, it'll turn everything on, wait for a few seconds, then turn everything back off again.

If that's not what you want, and instead you want all the particle systems to have a different wait time, you could use a coroutine!

 function Start () {
     for(var particles in BParticles)
     {
         StartCoroutine(OnOffParticles(particles));
     }
 }


 function OnOffParticles(var emitter : ParticleEmitter)
 {
     emitter.emit = true;
     yield WaitForSeconds (Random.Range(5, 10));
     emitter.emit = false;
 }

That will set a different, random timer on each particle system.

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 xDeltax · Oct 17, 2011 at 02:15 AM 0
Share

Problem solved. Thank you so much

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Emit particles along a animated mesh 1 Answer

Particles emit in the same direction twice if they hit a collider 0 Answers

(javascript) Activating an emitter through script 2 Answers

Particle Thrust 1 Answer

Freeze particles emitted with Shuriken 1 Answer

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