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 GC1983 · Jul 25, 2013 at 07:22 AM · joystickgamecontroller

USB Controller Guidance

Hello!

Im trying to understand what it is exactly I need to do to get a USB Logitech gaming controller to function with Unity. Is it Joystick that runs the DPad and GetButton that can run the controller butters? Is there something I have to add in so the code will recognize that the controller is plugged in? Any particular commands I should learn about?

Thanks!

Comment
Add comment · Show 1
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 AlucardJay · Jul 25, 2013 at 07:31 AM 1
Share

From my answer here : http://answers.unity3d.com/questions/489439/changing-first-person-controller-to-work-with-ouya.html

  • All the types of input are handled with the Input $$anonymous$$anager : http://docs.unity3d.com/Documentation/$$anonymous$$anual/Input.html

  • You set up axis and button inputs for each controller : Joystick Buttons (from a specific joystick): "joystick 1 button 0", "joystick 1 button 1", "joystick 2 button 0", ...

  • you build a test project, to check if the inputs are working : eg http://www.alucardj.net16.net/JoystickTest/JoystickTest.html

For example, here is a setup for the Input $$anonymous$$anager and a sample of script to use those inputs.

Input $$anonymous$$anager Settings :

alt text

Example Script :

 function TriggerInputs() 
 {
     var offset : float = 1.5;
     
     
     // - Triggers -
     
     if ( Input.GetAxis( "Left Trigger" ) > 0.02 )
     {
         leftTrigger.position.y = leftTriggerStartPos.y + ( offset * Input.GetAxis( "Left Trigger" ) );
         
         SetRendererColour( leftTrigger.renderer, selectedColour );
     }
     else
     {
         leftTrigger.position.y = leftTriggerStartPos.y;
         
         SetRendererColour( leftTrigger.renderer, defaultColour );
     }
     
     if ( Input.GetAxis( "Right Trigger" ) > 0.02 )
     {
         rightTrigger.position.y = rightTriggerStartPos.y + ( offset * Input.GetAxis( "Right Trigger" ) );
         
         SetRendererColour( rightTrigger.renderer, selectedColour );
     }
     else
     {
         rightTrigger.position.y = rightTriggerStartPos.y;
         
         SetRendererColour( rightTrigger.renderer, defaultColour );
     }
 }
 
 
 function BumperInputs() 
 {
     
     // - Left Bumper -
     
     if ( Input.GetButton( "Left Bumper" ) )
     {
         SetRendererColour( leftBumper, selectedColour );
     }
     else
     {
         SetRendererColour( leftBumper, defaultColour );
     }
     
     // - Right Bumper -
     
     if ( Input.GetButton( "Right Bumper" ) )
     {
         SetRendererColour( rightBumper, selectedColour );
     }
     else
     {
         SetRendererColour( rightBumper, defaultColour );
     }
 }

By the way, don't use my inputs! You should really setup an input for each joystick , eg :

 joystick 1 button 5
 joystick 3 button 1
 etc etc


0 Replies

· Add your reply
  • Sort: 

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

16 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

Related Questions

GameController Unity wrong Axis-Values 0 Answers

How can I able to get the Joystick movement values (Axis 6 and 7 ) in Android ..?, 0 Answers

keyboard commands to Joystik C# "Object reference not set to an instance of an object" 1 Answer

MobileSingleStickControl is not what I expected. 0 Answers

Joystick Character movement. 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