- Home /
Fire doesn't turn on with script
function Update () { // if the key is held during this update, we "toggle" the enabled value if (Input.GetKeyDown(KeyCode.W)) { particleEmitter.emit = !particleEmitter.emit; } }
Above is the code to turn the particl eemitter on and off. I have W for moving forward, and so the desired effect is while moving, particle emit, while not, particle stop, but i've tried;
GetKey GetKeyDown GetKeyUp
and none produced the desired results, they all either skipped turning off, skipped turning on, or just turned off/on at different times.
Answer by Krynn · Oct 23, 2010 at 04:22 PM
function Update ()
{
particleEmitter.emit = (Input.GetKey(KeyCode.W));
}
Thanks to oliver, this is the ammended, working script
Answer by Oliver Blitz · Oct 23, 2010 at 04:08 PM
I guess you want to make the emitter to fire particles as long as W is pressed, so try this:
function Update ()
{
particleEmitter.emit = (Input.GetKeyDown(KeyCode.W));
}
Thankyou but that doesn't work, all that does is do it for the one sec of pressing the key, not the holding, however, if anyone has the exact same problem, the solution was to change Get$$anonymous$$eyDown in Oliver's script to Get$$anonymous$$ey ^_^ thankyou oliver!