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
7
Question by apiotuch · Nov 19, 2009 at 08:35 PM · gamecontroller

How do I use an XBOX 360 controller in Unity?

How do I get started with controllers? I want to map controls to a 360/PC controller but I don't know where to begin? I'm having no problems with mapping controls to keyboard and mouse, but I don't know how to have Unity recognize my controller to begin with. Any help would be great, thanks in advance.

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 AdventureCapital · Jan 17, 2013 at 03:35 AM 0
Share

You should note that if you install the controller while Unity is running, it will not work until you restart the program. (Using model 1403;1086 and Unity 4.0.0f7).

6 Replies

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

Answer by Novodantis 1 · Nov 19, 2009 at 10:42 PM

Unity should recognise it so long as windows does (not sure how well 360 controllers work with Macs). If you plug in your 360 controller (wired works best) and get windows to see it fine under Game Controllers, you should have no problems using it in a Unity Game. Make sure you use Input.GetAxis and Input.GetButton rather than Keys, and check your Project>Input Settings for default button assignments to the joystick.

Edit: Two additional points: although the 360 controller works as-is on Vista and later, you will need to get a driver for XP to see it, much like the PS3 SixAxis does.

The other thing is, I would not recommend getting direct joystick keycodes in Unity; far better to use GetButtonDown("Fire1"), as that will be called if the user pressed left mouse button, left CTRL or Fire 1 on the joystick (by default). The user can also re-map the keys when using GetButton and GetAxis. Have a look at the 3D Platformer tutorial, you should find that works with controllers straight away. Interestingly, though, I found I had to invert the Y axis when using a controller or else the stick forward-back motion was the wrong way around.

Comment
Add comment · Show 2 · 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 numberkruncher · May 04, 2012 at 11:53 PM 0
Share

@$$anonymous$$ when using names like "Fire1" ins$$anonymous$$d of keycodes, is it possible to create custom names like "$$anonymous$$agic1"?

avatar image Mander · Jul 19, 2012 at 04:01 PM 0
Share

yea you can name it anyway you want in the inputmanager.

avatar image
5

Answer by Brian-Kehrer · Nov 22, 2009 at 02:31 AM

If you are using a Mac, or want to package a driver for mac, here is an open source driver.

Mac 360 Controller Driver

Also of note, check out Post on buttons mappings for a 360 controller

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
3

Answer by Kiyaku · Nov 19, 2009 at 11:51 PM

I tried it with a PS3 controller once. I had to:

  • Find a driver so Windows can recognize the PS3 Controller
  • Go to the GameController Settings in your Windows Systemsettings
  • Calibrate your controller (it is useful to write down which button is assigned to which number)
  • And use KeyCode.Joystick1Button0, KeyCode.Joystick1Button1, ... in Unity to get the Input.
Comment
Add comment · Show 1 · 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 dudedude123 · Feb 22, 2014 at 04:34 PM 0
Share

Or you can use a PS3 controller on a Linux

avatar image
3

Answer by melgu · Mar 17, 2012 at 12:11 AM

This should help...

http://unifycommunity.com/wiki/index.php?title=Xbox360Controller

Comment
Add comment · Show 2 · 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 dpk · Jun 07, 2013 at 06:35 PM 0
Share

Unfortunately this page is at best incomplete. It talks about stuff like X = "joystick button 2". But The input "joystick button 2" does not exist (unless you create it, I guess).

avatar image porglezomp · Jul 06, 2013 at 09:35 PM 2
Share

No, joystick button 2 is the proper name for it. You can create an axis in the input manager using that as the button. It works the same as "right ctrl", or "right shift", etc.

avatar image
2

Answer by Merrik44 · May 12, 2013 at 03:18 PM

I wrote a simple script to get controller input in the same way other keys are accessed. It also works with the web player.

GamePad.GetAxis(GamePad.Axis.Left, 1);

GamePad.GetButtonDown(GamePad.Button.A, 1);

You can download it here:

Comment
Add comment · Show 1 · 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 LilGames · Jun 13, 2017 at 04:07 PM 0
Share

This generic method works:

 float moveVertical = Input.GetAxis ("Vertical");

As does this with the CrossPlatformInput package:

 float moveVertical = CrossPlatformInput$$anonymous$$anager.GetAxis ("Vertical");

But make sure your Project Settings -> Editor -> Unity Remote has Joystick Source set to Local.

  • 1
  • 2
  • ›

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

8 People are following this question.

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

Related Questions

Terrain Tag OnControllerColliderHit not showing 0 Answers

How to find other gameObject's with same tag excluding itself 1 Answer

USB Controller Guidance 0 Answers

GCMouse and GCKeyBoard for Unity Games on IOS 14. Pointer Lock not working 1 Answer

Can I use the toon shading package in a fps environment? 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