Joystick 10th axis code problem

i have an interesting problem, this piece of code is inside the Update function and everything works fine besides “Input.GetAxis(“Fire1Jostick”) > 0.5”
when i pull the trigger the second axis is repeatedly fired causing the player to shoot 6 pistol rounds instantly

	if(Input.GetButtonDown("Fire1") || Input.GetAxis("Fire1Jostick") > 0.5){
		if(Trigger == true){
			Shoot();
			Trigger = false;
		}else{
			Trigger = true;
		}
	}

and this problem has not happened with the button so i know the code works(for a button)

BTW the Fire1Jostick is Axis 10(for xbox360 controller)

Thanks

The Update function is called every frame and Input.GetButtonDown() is only true for the one frame that the button is pressed. (See Unity - Scripting API: Input.GetButtonDown) So, your condition to fire is true only once when using that button and you get one call to Shoot().

On the other hand, Input.GetAxis() reports the status of the axis every frame. Since you won’t likely have the trigger pulled for only one frame, your condition to fire is true for several frames. The same sort of thing will happen when you use Input.GetButton(), which reports true not just for the frame it’s pressed, but for every frame while it’s held. So, you get many calls to Shoot().

They typical solution for a single shot with this kind of input, is to save a bool for if a shot was fired and only reset this once the button up condition is met.

Here is an answer with a code example

If you wanted auto-fire, you could watch Time.time to see if enough time has passed since the last bullet was shot. Then that will be an additional condition for shooting that bullet.