Welcome!

Welcome to our community forums, full of great people, ideas and excitement. Please register if you would like to take part.

This is extra text with a test link..

Register Now

Announcement

Collapse
No announcement yet.

My gun is firing and killing zombies when I don't have it

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • My gun is firing and killing zombies when I don't have it

    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.
    Attached Files

  • #2
    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

    Working...
    X