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 user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
No one has followed this question yet.
Working On A Sudo Fluid System
How to create "soap bubble" graphic effect?
Particle system not destroying.
GameObject block particles?! help