# The value of animation parameter is not changing?

Code:

var click=false;
var anmtr:Animator;

function Update () {

if(Input.GetButtonDown("Fire1")){

click=!click;
anmtr.SetBool("clk",click);
}

if(Input.GetButtonUp("Fire1")){

click=!click;
}


}

The value of click variable in inspector is changing as I click and release the mouse button.But the value of the Animation parameter is changed from false to true on first button down event and then it stays true forever even after releasing the mouse. No matter how many times I click the mouse button it stays true. But not the variable click it changes as expected.

• sorry found the error – coder_86 Jun 28 '17 at 12:27

The reason is, when you release the button, you don't update the anmtr; Since you are just toggling the bool in both if's, you could simply do this:

if(Input.GetButtonDown("Fire1") || Input.GetButtonUp("Fire1") ){
click=!click;
anmtr.SetBool("clk",click);
}