Animator parameter stays true after mouse button released.

Hi guys,

I’m currently scripting my weapon to work with the animator component. The weapon fires ray cast and does everything it needs to just fine. The problem seems to lie within the animator.

It is supposed to play the ‘fire’ animation (on a loop) when “Fire1” is held down and go back to ‘idle’ or ‘walk’ when “Fire1” is released.The parameter for this is a bool. So as you can guess when “Fire1” is held down the bool goes to ‘true’. However, after releasing “Fire1” the bool does not return to ‘false’ and simply stays ‘true’.

Fire1 released after being pressed

I’ve included all the snippets of code that I think are relevant to the function of this.

//variables
    var fireRate : float = 0.5;
    private var nextFire : float = 0.0;
    
    //--//
    
    if(player_AllowFire) //player is allowed to fire?
    	{
    		if(Input.GetButton("Fire") && !Input.GetButton("Sights") && Time.time > nextFire) //did the player just hit the "fire" button?
    		{
    			PullTrigger(); //pull the trigger - (not firing yet)
    		}
    	}
    //code continues
    //==//
    
    function PullTrigger() //trigger pulled- now it's either "click!" or "bang"
    {
    	if(currentWeapon.clipAmmo != 0 && Input.GetButton("Fire") && !Input.GetButton("Sights") && Time.time > nextFire) //are there still bullets in the clip? 
    	{
    		nextFire =  Time.time + fireRate;
    		currentWeapon.gameObject.GetComponent(AudioSource).PlayOneShot(currentWeapon.sfx_WeaponFire); //play weapon fire audio, just once
    		
    		animator.SetBool("Fire",true);

    //code continues for a bit (still the same function below)

    else //uho, no bullets in the clip- click click PANIC!
    	{
    		animator.SetBool("Fire",false);
    }

Can anyone figure out what is happening here?

My god I’m an idiot. I forgot to add in an else statement in the section before the PullTrigger function. There was no condition for the parameter to be false except for when the player runs out of ammo! Fixed now:

if(player_AllowFire) //player is allowed to fire?
	{
		if(Input.GetButton("Fire") && !Input.GetButton("Sights") && Time.time > nextFire)
		{
			PullTrigger(); //pull the trigger - (not firing yet)
		}
		else
		{
			animator.SetBool("Fire",false);
		}