- Home /
This question was
closed Jun 13, 2014 at 09:21 PM by
tanoshimi for the following reason:
Duplicate of: http://answers.unity3d.com/questions/726919/problem-with-if-statements.html http://answers.unity3d.com/questions/726919/problem-with-if-statements-2.html
Question by
SterlingStudios · Jun 13, 2014 at 08:37 PM ·
gunif
Problem with "if" statements
Hi. I have a problem with multiple items under an "if" statement. I want all of these to happen. Here's the code:
function GunFX () {
if(Input.GetMouseButtonDown(0) && canShoot == true)
gunShotFX.active = true;
yield WaitForSeconds(1);
gunShotFX.active = false;
audio.PlayOneShot(gunShotSound);
}
Comment
Is your GunFX function getting called? Are you making sure *canShoot == true*
? Add a *Debug.Log*
function to see if it gets called.
As was said in the other two places you posted this, you're missing the curly braces around the if body...
you need to write:
if(Input.Get$$anonymous$$ouseButtonDown(0) && canShoot == true)
{
gunShotFX.active = true;
yield WaitForSeconds(1);
gunShotFX.active = false;
audio.PlayOneShot(gunShotSound);
}
Follow this Question
Related Questions
Problem with "if" statements 1 Answer
Problem with "if" statements 1 Answer
Creating laser gun effect. 1 Answer
Timing Between each Gun Shot 2 Answers
Character Rotation Doesn't work 0 Answers