x


Why are these objects there from the beginning?

Hello,

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"

Picture

more ▼

asked Dec 01, 2009 at 11:54 AM

MrJames gravatar image

MrJames
35 11 12 18

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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!

more ▼

answered Dec 01, 2009 at 12:02 PM

duck gravatar image

duck ♦♦
47.8k 131 233 472

Thanks, this works fine: Smoke.particleEmitter.emit = true; But wouldn't this be bad for performance for bigger projects?

Dec 01, 2009 at 12:11 PM MrJames

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.

Dec 01, 2009 at 12:46 PM duck ♦♦
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3637
x1030
x836

asked: Dec 01, 2009 at 11:54 AM

Seen: 1370 times

Last Updated: Dec 01, 2009 at 02:55 PM