Weapon switching problem.

#pragma strict
function Update ()
{
if (Input.GetAxis(“Mouse ScrollWheel”))
{
SwapWeapons();
}
}

 function SwapWeapons () 
    {
    	if (Weapon01.active == true) 
    	{
    		Weapon01.SetActive(false);
    		Weapon02.SetActive(true);
    	} 
    	else 
    	{
    		Weapon01.SetActive(true);
    		Weapon02.SetActive(false);
    	}	
    }

Using this code I am getting an weird “bug” where it is running the if and the else with one scroll of the wheel. I’ve worked on this all day but I haven’t found a solution.

Swap 2 weapons.

	function Update (){
		var f = Input.GetAxis("Mouse ScrollWheel");
		if(f > 0 || f < 0)
			SwapWeapons();
	}

If you need change 3 or more weapons.

	function Update (){
		var f = Input.GetAxis("Mouse ScrollWheel");
		if(f > 0)
			NextWeapon();
		if(f < 0)
			PreviewWeapon();
	}

and so on…