Script not changing boolean

So i have this script:

  • #pragma strict
    • public var IsShooting : boolean = false;
    • function Update (){
    • if(Input.GetButtonDown (“Fire1”)){
  • IsShooting = !IsShooting; // toggles onoff at each click
    • if (IsShooting){
  • print(“You’re shooting!”);
  • } else {
  • print(“Not shooting”);
  • }
  • }
  • }

I found it on the forums as an answer, just to try it out but it’s not working(doing something wrong most likely).
So i have 2 problems.

1- It does enable and prints “You’re shooting!”, but doesn’t change the bool in the parameter:/
2- I also have no clue how to make it so when i hold it, it shoots, instead of toggling. I did try changing a few things here and there like IsShooting = True; then on button release IsShooting = False; But it was constantly on. So i went back to the original script :confused:

The bool’s name is also “IsShooting”
It’s attached to the weapon “Mac-10” which is the gameobject with the animator and controller.

So any help would be appreciated :smile:

I just realised, this doesn’t change the animator boolean does it? Can someone confirm that?

no it doesn’t, you need to pass the value to the animator with a call to
animator.SetBool()

Ye i got it, ty:smile: