Xbox 360 Controller (on Mac): Trigger initialises at "0" at game startup, but trigger itself is at position "-1", how can I get the correct value at startup?

How do I reconcile the fact that on Mac, the right trigger of an Xbox 360 controller returns a value of “0” when the game first begins, but the trigger axis itself is not being pressed and should initialise with a value of “-1”.

Currently, I have to press the button once, then release it, then it gives me the proper -1 value. But when the game first starts, it’s giving me the wrong value.

I want my character to jetpack around, and I’m trying to use the right trigger to return a value from 0 to 1.

I do a Math.Lerp to get the right trigger (on Mac this is called Axis 6) to turn the -1 to +1 range to a 0 to 1 range.

It all works great, except that when I start the game, my character immediately starts using their jetpack, because the controller says that the triggers are at position “0”, when actually, they’re at position “-1”, because they’re not being pressed.

Once I press the triggers, they reset properly, and give values -1. I just don’t know how to force the controller to give a proper -1 reading at game startup! Any ideas?

  • Murray

I ran into the same issue, in addition I needed to normalize the numbers between 0-1.

Here is the code I used to fix it, hope someone finds this useful.

float macReadTrigger () {
	
	float adjustedAxis = 1.0f;
	timeAxis = Input.GetAxisRaw("Trigger");

	if((timeAxis > -0.9f && timeAxis < -0.0001f) && readyToShiftTrigger == false) {
		readyToShiftTrigger = true;
	}
	
	if(readyToShiftTrigger) {
		//Debug.Log("TIME SHIT: " + timeAxis);
		if(timeAxis == -1) {
			adjustedAxis = 0;
		} else if(timeAxis > -1 && timeAxis < 0) {
			adjustedAxis = (timeAxis * -1.0f) * 0.5f;
		} else if(timeAxis == 0) {
			adjustedAxis = 0.5f;
		} else if(timeAxis > 0 && timeAxis < 1) {
			adjustedAxis = (timeAxis + 1.0f) * 0.5f;  
		} else if(timeAxis == 1) {
			adjustedAxis = 1;
		}
		
	}
	

	return adjustedAxis;
}