Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ytwithlove · Jul 15, 2014 at 03:46 AM · zoominputmanagerinput managerxboxcontrollerxbox controller

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:

alt text

Any suggestions?

zoombtn.png (9.4 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ytwithlove · Jul 19, 2014 at 02:03 AM

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. ^_^

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;
             }
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Chris_Dlala · Jul 15, 2014 at 08:33 AM

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 =)

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ytwithlove · Jul 15, 2014 at 11:59 AM 0
Share

I got pretty far using that but I can't seem to figure out what the triggers are. That probably sounds really weird so I'll explain.

I have the axis set up as the 3rd axis like the picture shows on the Unify site and what I have on my screen shot. I'm not sure what to put for the positive button - I know it mentions the triggers being 0 and 1 but I don't understand what that means.

Do I need to place LT as 0 and RT as 1?

I hope that makes sense and doesn't sound confusing.

avatar image tanoshimi · Jul 15, 2014 at 12:05 PM 0
Share

You use Input.GetAxis("Zoom"); - if the result is 1 then the right trigger is pressed. If it's -1 then the left trigger is pressed.

avatar image ytwithlove · Jul 16, 2014 at 01:26 AM 0
Share

Unfortunately using Input.GetAxis("Zoom"); didn't get any response from either trigger. And I still wasn't able to get the controller to work using the Unify example.

I'll keep picking at it and see what I can come up with.

avatar image ytwithlove · Jul 19, 2014 at 12:41 AM 0
Share

I kept messing with the code and was able to map something to the triggers but the $$anonymous$$imap keeps zoo$$anonymous$$g too far out and won't switch back.

Here's the code I came up with:

 if(Input.GetAxis("360_Triggers") >=0.001 ) 
 { 
      camera.orthographic = true; 
      camera.orthographicSize += 40; 
 } 
 else 
 { 
 camera.orthographic = true; 
 camera.orthographicSize -=40;
 }

Any suggestions to stop the consistent zoo$$anonymous$$g?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Xbox Controller RT Button does not revert to 0 until other input is applied (some times) 0 Answers

How to create Halo-like Split Screen system? 0 Answers

Input.GetJoystickNames gives incorrect index with multiple controllers 1 Answer

Xbox controller double input (right stick axis) 0 Answers

One Xbox Controller Is Affecting All Players 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges