Using Trigger Keys on Xbox Controller To Zoom

I’ve looked just about everywhere and haven’t been able to find a solution so I figured I’d ask the knowledgeable masses.

I’m trying to set up my Right Trigger on my Xbox360 controller to zoom in to a certain point on a map when pressed 1 time. If pressed a second time, the map should go back to the overhead view it started at.

I’ve run into 2 problems:
Problem 1: I have the zoom working but it keeps zooming in or out when pressed multiple times by any of the controller buttons I get to work.

Problem 2: I can’t seem to figure out what the number for the Left and Right Triggers are for the Xbox Controller.

I’m currently debugging my code by using this and checking the console:

if (Input.GetButtonDown("Zoom"))
{
     Debug.Log("Trigger is pressed");
}

And my input button is set up like this:

29223-zoombtn.png

Any suggestions?

Hi, a while back I used Unify Community’s page on Xbox360 controllers to get the mappings. They include a copy of InputManager.asset with all the entries for the Xbox controller. As for problem one, it sounds like that’s what you wanted? I can only suggest storing the state of the zoom and checking against the state when the input is pressed. I hope that helps =)

Figured it out! Got an assist from a friend with my code but it looks like I was on the right track. Needed to create a bool variable then check against it so I could toggle the map. Ended up using a different button to get it to work but at least it works now. :slight_smile:

Here’s the code I was able to get to work:

//Variable
bool isZoomed = false;

Update()
{
if(Input.GetButtonDown("360_RightBumper"))
		{
			if (isZoomed) {
				camera.orthographicSize = 44;
				isZoomed = false;
			} 
			else 
			{
				camera.orthographicSize = 14;
				isZoomed = true;
			}
}