Help with particles array

Yesterday I created a marginally adequate star generator to populate my galaxy with stars. The method I chose for this was to make a prefab and instantiate it for every star. In other words, every star is a billboard and its own gameobject.

This was apparently a mistake on my part, because:

  • I could create only around 4000 stars before the frame rate started lagging.
  • And, when I tried to animate each star with a twinkle effect (via changing color.a), the framerate dropped horrendously to about 1-5 fps. this effect was as a script attached to each gameobject.

Then last night NCarter on IRC said I should render all of the stars as a particle array of a particleEmitter. I have tried to do this rather unsuccessfully by building a generic list of stars (and their data as a class) and iterating over the list to build an array of particles. No errors occur, but no stars render either.

Can anyone tell me how to create particles via script, or point me somewhere that does?

Instead of making a single star per game object you can group them into clusters, you can also instantiate them as they’re required rather than all at once and get rid of the ones that out of view.

Thank you, but that is not possible in this game. Or at least not very helpful. It is a strategy game where the player continuously has the entire galaxy in view.

I apologise in advance for how banal this reply is. Have you made sure you’ve got a Particle Renderer attached to your Particle Emitter? Particles won’t render without this.

Next thing to check is the texture of your particles. Followed by the transparency settings of your particles material. Need any more help, feel free to ask. I know a reasonable amount about particles having wasted more time than I should on them.