- Home /
input.getbutton/whatever
hey folks!
input.getbutton/whatever() is being called every frame in the update() function, meaning that it will execute my code inside the {} of my input.whatever when i PRESS or HOLD DOWN the button. meaning it will also stop executing my code once i RELEASE the button.
my question is, does anyone know how to execute the code without having to hold down the code?
sorry for the CAPS folks, that's where i want u guys to focus. any help is appreciated, thank you very much.
Rubbish capitalisation just makes your question hard to read. If you want to highlight something, use italics or bold. Save your capitals for the beginnings of sentences and proper class names.
Answer by Waz · Jul 21, 2011 at 09:14 PM
You want GetButtonDown instead, and upon it, set a variable. Something like:
if (Input.GetButtonDown("flameOn")
flame = true;
if (flame)
particles.Emit(5);
Presumably you wany another button to flame off, or toggle it:
if (Input.GetButtonDown("flameOn")
flame = !flame;
Your answer
![](https://koobas.hobune.stream/wayback/20220612152628im_/https://answers.unity.com/themes/thub/images/avi.jpg)