I didn't have this problem before. But now when I play, every time I hit Fire1 my gun will play the gun shot audio, and if I shoot a zombie without my having my handgun my zombies will take damage. I tried turning off the bools under the inventory until the player gets the gun, but that didn't work. I also tried making "else" functions under the "Fire1" and "KeyCode."E"" (what I currently have) but nothing is working. Any help is appreciated.
Announcement
Collapse
No announcement yet.
My gun is firing and killing zombies when I don't have it
Collapse
X
-
In your current code (look at the third screenshot), when you press fire, you never check to see if canFire is true before firing. So you've got to have something like:
Code:if(Input.GetButtonDown("Fire1")) { if(canFire) { if(Physics raycast stuff) { all the stuff to do if we're origin the gun } } }
Comment