- Home /
Button Particle Emission
I have this, i want particles to emit when i press space, and to stop when i realease.
function FixedUpdate() {
if (Input.GetKeyDown ("space")) { particleEmitter.emit = true; }
if Input.GetKeyUp ("space")) { particleEmitter.emit = false; } }
but it comes up with errors. What am i doing wrong?
Answer by Eric5h5 · Apr 17, 2010 at 09:28 PM
You're missing a parenthesis in the second if
statement. Also, don't use GetKeyDown or GetKeyUp in FixedUpdate, because those events are only true during the one frame that they're activated, and FixedUpdate doesn't run every frame. Only use FixedUpdate for physics.
Also, sometimes it doesn't turn off when i release Space, is this just a unity bug?
@Fishman92: It's not a bug. I edited my answer to add more info about that.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172013im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Collision with Particle Systems 3 Answers
Particles for dreamy smoke-like effects and bubbles 2 Answers
Is it possible to make particles travel in a parabolic arc? 1 Answer
How to lower thee effect of Gravity on Particles?/Shorter Trail when moving. 0 Answers
Texture Sheet Animation ....on a mesh? 0 Answers