i've created some ParticleSystems and want to initiate them with some keys. To destroy these objects works fine, but i can't create them, because they are always in my gmae from the beginning. But non of my scripts call them? Here's a picture of my hierarchie: the two particle systems are "Smoke" and "flame"
Answer by duck
Dec 01, 2009 at 12:02 PM
I don't entirely understand your question, but if your goal is just to trigger some Smoke or Flame at certain moments in your game, it would probably be a better approach to toggle the .emit flag to true and false at those times, rather than actually create and destroy your particle system GameObjects.
You can keep the Particle System GameObject present in your scene the whole time. Just un-check 'emit' in the editor, and when you need some smoke or flame in your game, use scripting to set the position of the particle system, and set the .emit value to = true. Then, a few seconds later, set it back to false to stop the emitter.
If you want to trigger these emitters when a key is pressed, you'll need to use either Input.GetKey or Input.GetKeyUp. Click those links for the documentation.
hope this helps!
Thanks, this works fine: Smoke.particleEmitter.emit = true; But wouldn't this be bad for performance for bigger projects?
No, particle emitters are very well optimized. All the particles for a given emitter are drawn as if they were a single mesh, which is great for keeping your draw calls down.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
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.
Answers and Comments
No one has followed this question yet.
2D Destroy GameObject on small parts, without having each part pre-defined
GameObject block particles?! help
How i can put gameObject into GuiTexture?
Is it possible to create a speed particle system to form into Text?
How do You Display Energy Etc Screen Indicators?