- Home /
muzzle flash is malfunctioning
hello,i'm kinda bad at scripting but so far this is one of my best scripts i put together and its just this one last step that isn't working for me and that's the input functions i'm having a hard time getting the muzzle flash to work when i press the left mouse key instead the muzzle flash works when i press any button on my keyboard i have tried to switch the inputs around and i still cant get it to work i'm pretty sure this is a simply fix i just need help so can someone please help me,thanks here's my script
#pragma strict
var muzzleFlash : ParticleEmitter;
var lightone : GameObject;
var lighttwo : GameObject;
var lightthree : GameObject;
function Start() {
muzzleFlash.emit = false;
}
function Update () {
if(!Input.GetKeyDown(KeyCode.Mouse0))
{
muzzleFlash.emit = true;
lightone.active = true;
lighttwo.active = true;
lightthree.active = true;
}
if(Input.anyKey == false)
{
muzzleFlash.emit = false;
lightone.active = false;
lighttwo.active = false;
lightthree.active = false;
}
}
Answer by Inan-Evin · Feb 07, 2015 at 04:33 PM
There is an exclamation mark right before the Input.GetKeyDown part, it means "if not". So what you should be doing is :
if(Input.GetKeyDown(KeyCode.Mouse0))
{
muzzleFlash.emit = true;
lightone.active = true;
lighttwo.active = true;
lightthree.active = true;
}
else{
muzzleFlash.emit = false;
lightone.active = false;
lighttwo.active = false;
lightthree.active = false;
}
Your answer
Follow this Question
Related Questions
Muzzle Flash Not Working 0 Answers
Gun Muzzle Flash 2 Answers
Instantiating Muzzle Flash 1 Answer
Add force to Instantiated object. 4 Answers