Search Unity

Like most mobile games developers, we’ve been closely following what important additions and changes the recently released iOS 7 update has made. One of the biggest and most exciting of Apple’s initiatives is the standardization of game controllers for iOS-based platforms. So we’re happy to tell you that, in addition to several important bug fixes for Xcode 5 / iOS 7 (Build&Run, WebCamTexture and status bar), Apple Controller support is included with 4.2.2! This blog post aims to answer most common questions this addition will raise and serve as a short tutorial on how to add support for iOS Game Controllers to your game.

Lets start with the questions you probably have:

  • Q: Will there be a separate iOS-specific API for iOS Game Controllers in Unity?
    A: iOS Game Controller support plugs directly into the standard Unity Input API.
  • Q: The Game Controller API is part of iOS 7, does that imply that games supporting this API will only run on iOS 7 and later?
    A: No, Unity takes care of it. The Game Controller framework is loaded dynamically by Unity iOS runtime only if it is available. For older iOS versions it will just return an empty list of controllers.
  • Q: Can I release my game with a controller-only input scheme?
    A: No, Apple documentation explicitly states that controller input must be optional and your game should be playable without them.
  • Q: Where can I read more about Game Controllers and the Unity Input API?
    A: The Unity Input manual is available from our manual page and Apple Game Controller documentation is here.

Ok, now it’s probably time to write some code ;)

The first thing you probably want to do is detect whether a controller is connected and, if so, what type of controller it is. Call Input.GetJoystickNames() to enumerate attached controller names. If the list is empty, there are no controllers attached. It’s worth checking it every several seconds to detect if controllers have been attached/detached. Here’s an example in C#:

When controllers are detected you can either hide on-screen touch controls or amend them to supplement controller input. The next task is to check for Game Controller input. Your actual input scheme is highly dependent on the type of game you are developing. Lets take a look at the upcoming Unity 2D tutorial as a simple example:

bean

The player controls the bean character, which can move right or left, jump and fire at the bad guys. By default, the Unity Input “Horizontal” axis is mapped to basic profile game controller dpad and the left analog stick on extended profile controllers. So the code used to move the character back and forth is pretty simple:

You can set up jump and fire actions in Unity’s Input Manager. Access it from the Unity editor menu as follows: Edit > Project Settings > Input. Lets pick joystick button “A” for the “Jump” action and “X” for “Fire”. Open the following actions in the Unity Input Manager and specify “joystick button 14” for “Jump”  and “joystick button 15” for “Fire”.

JumpAndFire

The code handling them looks like this:

The following cheatsheet should help you map controller input in the Unity Input Manager:

Name KeyCode Axis
A joystick button 14 N/A
B joystick button 13 N/A
X joystick button 15 N/A
Y joystick button 12 N/A
Left Stick N/A Axis 1 (X) – Horizontal, Axis 2 (Y) – Vertical
Right Stick N/A Axis 3 – Horizontal, Axis 4 – Vertical
Dpad joystick button 4 .. joystick button 7 Basic profile only: Axis 1 (X) – Horizontal, Axis 2 (Y) – Vertical
Pause joystick button 0 N/A
L1/R1 joystick button 8/joystick button 9 N/A
L2/R2 joystick button 10/joystick button 11 N/A

That’s all you need to start adding iOS Game Controller support to your games!

24 replies on “Unity 4.2.2 brings iOS Game Controller support”

Also, what is the correct method to use to determine whether or not the extended profile is available? There are two types, one has triggers and sticks and one does not.

All the controls on an MFI controller are analog. It would be very useful to have access to the actual values returned (0-1). While most of the time, analog is not useful for buttons, it might be, and it is clearly Apple’s expectation.

[…] create countless titles for iOS and other platforms, got a 4.2.2 update that the company announced via its blog on Friday. Among the changes is support for game controllers in iOS, according to […]

[…] The Unity game engine likes to take things in small steps. First it was adding Linux and Wii U support. Then Windows 8, Windows Phone 8 and BlackBerry 10. Now that most of the major operating systems are covered, it's time to start making minor enhancements to that support. With version 4.2.2, released today, it now supports iOS 7's native game controller API. Apple decided to standardize controllers across iOS, making it easier for developers to build in gamepad support. It was also trivial for the Unity team to plug that API directly into its own standard Unity input API. For more details you can check out the Unity developer blog. […]

Just to make clear, iOs7 has built in framework for the new controllers,This is to standardize game controller support on Apple devices, as to what controller is supported the answer is any Game Controller that declares itself as an “MFi Game Controller”, this is the key wording that tells us it is officially supported by Apple and will work with iOs7. keep a lookout for Logictech & Moga MFi Controllers.

Very helpful and useful article to get the latest technological news. So it will be more reliable to get the free online software and so on.
Thanks and wishing the success.

It seems that Unity 4.2.2 is of great utility, though we have not experienced it at the personal level. Such codes and guidance have made the jobs of mobile apps and games developers much easier, who have been fulfilling the need of newer games and apps for tapjoy, adcolony, admob, revmob, appnext, chartboost

[…] introductory tutorial has been posted on Unity’s blog, guiding developers through the basics of setting up their games for a controller and offering […]

[…] The 4.2.2 update for Unity, the multiplatform game development software, adds support for iOS controllers, according to a recent post on Unity Technology’s official blog. […]

[…] The 4.2.2 update for Unity, the multiplatform game development software, adds support for iOS controllers, according to a recent post on Unity Technology’s official blog. […]

[…] Technologies announced that the version 4.2.2 of their SDK provides support for iOS game […]

I have a few questions about this:
1. How do we detect if it is Basic or Extended Profile.
2. If you din’t give us a clear way to detect it at least you shouldn’t have mixed the inputs between the 2 types (Axis 1 = Left Stick = Dpad).
3. Why is dpad separatly maped for Basic And Extended profile? (this makes implementing controller suport for Basic and Extended in the same proiect a nightmare!!!)

Thanks for including this into Unity, But please rethink the mapping + detection
Thanks,
Bari

[…] The Unity game engine likes to take things in small steps. First it was adding Linux and Wii U support. Then Windows 8, Windows Phone 8 and BlackBerry 10. Now that most of the major operating systems are covered, it’s time to start making minor enhancements to that support. With version 4.2.2, released today, it now supports iOS 7′s native game controller API. Apple decided to standardize controllers across iOS, making it easier for developers to build in gamepad support. It was also trivial for the Unity team to plug that API directly into its own standard Unity input API. For more details you can check out the Unity developer blog. […]

[…] profiter de ces dernières pour concevoir des contrôleurs physiques compatibles avec iOS 7. Unity compte bien se mettre sur ce segment en proposant des jeux 3D parfaitement adaptés avec les […]

[…] Unity framework ก็ออกมาประกาศผ่านทางบล็อกว่าในเอนจินเกมเวอร์ชันล่าสุด 4.2.2 […]

[…] Unity опубликовала SDK под версией 4.2.2. Его главное нововведение – […]

[…] developer, Unity, has announced that it is now going to add support for game controllers for those that are using iOS 7. Unity […]

[…] La buena noticia esta vez es que los de Unity han decidido dar soporte a la nueva API de iOS 7 para los controladores y mandos dedicados de terceros. Así lo anuncian en su blog. […]

[…] La buena noticia esta vez es que los de Unity han decidido dar soporte a la nueva API de iOS 7 para los controladores y mandos dedicados de terceros. Así lo anuncian en su blog. […]

[…] developer, Unity, has announced that it is now going to add support for game controllers for those that are using iOS 7. Unity […]

[…] Il resto del post, come appena sottolineato, si preoccupa di fornire spiegazioni tecniche su come implementare il supporto ai controller. Se vi interessa potete fare un salto qui. […]

[…] 在今天刚刚发布的 4.2.2 版本中,我们看到 Unity 已经开始支持 iOS 7 的原生游戏控制器 API 了。苹果为所有 iOS 控制器制定统一标准的决定无疑让开发者们受益良多,后者如今在制作支持软件时比过去要方便了不少。除此之外,Unity 团队还将苹果的 API 加入到了自己的标准 Unity 输入 API 之中,想了解更多详细内容的话可以去他们的开发者博客看一看。 […]

[…] 在今天刚刚发布的 4.2.2 版本中,我们看到 Unity 已经开始支持 iOS 7 的原生游戏控制器 API 了。苹果为所有 iOS 控制器制定统一标准的决定无疑让开发者们受益良多,后者如今在制作支持软件时比过去要方便了不少。除此之外,Unity 团队还将苹果的 API 加入到了自己的标准 Unity 输入 API 之中,想了解更多详细内容的话可以去他们的开发者博客看一看。 […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] create countless titles for iOS and other platforms, got a 4.2.2 update that the company announced via its blog on Friday. Among the changes is support for game controllers in iOS, according to […]

[…] 在今天剛剛發佈的 4.2.2 版本中,我們看到 Unity 已經開始支援 iOS 7 的原生遊戲控制器 API 了。Apple 為所有 iOS 控制器製定統一標準的決定無疑讓開發者們受益良多,後者如今在製作支援軟體時比過去要方便了不少。除此之外,Unity 團隊還將 Apple 的 API 加入到了自己的標準 Unity 輸入 API 之中,想了解更多詳細內容的話可以去他們的開發者部落格看一看。 […]

[…] Неплохо бы заполучить и фирменный игровой аксессуар от Apple, но пока имеем то, что имеем. Пример Unity уже говорит о многом. Например, о том, что явно пришло время для внешних джойстиков, которые можно использовать с iOS-устройствами. В Купертино ведь тоже не дураки сидят и отслеживают тенденции рынка. Пример Unity может стать решающим толчком для появления соответствующих устройств. К тому же на конференцииTech Talks 2013 компания Apple впервые разделила игровую разработку и прикладные приложения, что тоже дает тонкий намек на толстые обстоятельства. [Unity] […]

[…] APIs by developers has been slow as customers cannot yet take advantage of the feature. Today, the Unity framework announced on its blog that the newest version of its game engine surfaces inputs from these controllers natively in the […]

[…] Unity 输入 API 之中,想了解更多详细内容的话可以去他们的开发者博客看一看。 经由:Engadget […]

[…] 在今天刚刚发布的 4.2.2 版本中,我们看到 Unity 已经开始支持 iOS 7 的原生游戏控制器 API 了。苹果为所有 iOS 控制器制定统一标准的决定无疑让开发者们受益良多,后者如今在制作支持软件时比过去要方便了不少。除此之外,Unity 团队还将苹果的 API 加入到了自己的标准 Unity 输入 API 之中,想了解更多详细内容的话可以去他们的 开发者博客看一看。 […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] Unity Engine, uno dei motori grafici più utilizzati in ambito mobile, che ha permesso di sviluppare innumerevoli titoli su iOS ed altre piattaforme, si aggiorna alla versione 4.2.2, ne fa voce la società attraverso un annuncio nel blog ufficiale. […]

[…] Unity Engine, uno dei motori grafici più utilizzati in ambito mobile, che ha permesso di sviluppare innumerevoli titoli su iOS ed altre piattaforme, si aggiorna alla versione 4.2.2, ne fa voce la società attraverso un annuncio nel blog ufficiale. […]

[…] This welcome development was announced by the Unity team in a new blog post: […]

[…] Unity, la librería de desarrollo detrás de una multitud de aplicaciones iOS, ha sido actualizada a la versión 4.2.2 añadiendo soporte para los controles de juego en iOS 7. […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] and serve as a short tutorial on how to add support for iOS Game Controllers to your game.— Mantas Puida […]

[…] and serve as a short tutorial on how to add support for iOS Game Controllers to your game.— Mantas Puida […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] Unity wordt onder andere gebruikt in Call of Duty: Strike Team, The Room en Bad Piggies. In de vernieuwde versie van Unity (4.2.2) zijn nog wat meer verbeteringen doorgevoerd, maar waar het meest naar wordt uitgekeken is […]

[…] APIs by developers has been slow as customers cannot yet take advantage of the feature. Today, the Unity framework announced on its blog that the newest version of its game engine surfaces inputs from these controllers natively in the […]

[…] APIs by developers has been slow as customers cannot yet take advantage of the feature. Today, the Unity framework announced on its blog that the newest version of its game engine surfaces inputs from these controllers natively in the […]

[…] Unity Engine, uno dei motori grafici più utilizzati in ambito mobile, che ha permesso di sviluppare innumerevoli titoli su iOS ed altre piattaforme, si aggiorna alla versione 4.2.2, ne fa voce la società attraverso un annuncio nel blog ufficiale. […]

[…] of Unity’s weblog (by […]

[…] From Unity’s blog (via MacRumors): […]

[…] Unity Engine, uno dei motori grafici più utilizzati in ambito mobile, che ha permesso di sviluppare innumerevoli titoli su iOS ed altre piattaforme, si aggiorna alla versione 4.2.2, ne fa voce la società attraverso un annuncio nel blog ufficiale. […]

[…] Unity 4.2.2 brings iOS Game Controller support – Unity Technologies Blog […]

[…] Unity Engine, uno dei motori grafici più utilizzati in ambito mobile, che ha permesso di sviluppare innumerevoli titoli su iOS ed altre piattaforme, si aggiorna alla versione 4.2.2, ne fa voce la società attraverso un annuncio nel blog ufficiale. […]

[…] The Unity game engine likes to take things in small steps. First it was adding Linux and Wii U support. Then Windows 8, Windows Phone 8 and BlackBerry 10. Now that most of the major operating systems are covered, it’s time to start making minor enhancements to that support. With version 4.2.2, released today, it now supports iOS 7′s native game controller API. Apple decided to standardize controllers across iOS, making it easier for developers to build in gamepad support. It was also trivial for the Unity team to plug that API directly into its own standard Unity input API. For more details you can check out the Unity developer blog. […]

[…] a reply Unity, the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] create countless titles for iOS and other platforms, got a 4.2.2 update that the company announced via its blog on Friday. Among the changes is support for game controllers in iOS, according to […]

[…] pretty major development in the wacky world of MFi Controller news materialized today as Unity announced on their blog that their forthcoming 4.2.2 update will include iOS 7 Controller support. The blog post covers […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] create countless titles for iOS and other platforms, got a 4.2.2 update that the company announced via its blog on Friday. Among the changes is support for game controllers in iOS, according to […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] create countless titles for iOS and other platforms, got a 4.2.2 update that the company announced via its blog on Friday. Among the changes is support for game controllers in iOS, according to […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] The Unity game engine likes to take things in small steps. First it was adding Linux and Wii U support. Then Windows 8, Windows Phone 8 and BlackBerry 10. Now that most of the major operating systems are covered, it’s time to start making minor enhancements to that support. With version 4.2.2, released today, it now supports iOS 7′s native game controller API. Apple decided to standardize controllers across iOS, making it easier for developers to build in gamepad support. It was also trivial for the Unity team to plug that API directly into its own standard Unity input API. For more details you can check out the Unity developer blog. […]

[…] pretty major development in the wacky world of MFi Controller news materialized today as Unity announced on their blog that their forthcoming 4.2.2 update will include iOS 7 Controller support. The blog post covers […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] 11, 2013 4:08 pm PDT by Juli Clover Unity, the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] informierte über das Update im hauseigenen Blog und veröffentlichte gleich ein kleines Codebeispiel für die Implementierung des […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] the engine behind a multitude of iOS apps, was today updated to version 4.2.2, adding iOS Game Controller support. According to the release notes, iOS game […]

[…] The Unity game engine likes to take things in small steps. First it was adding Linux and Wii U support. Then Windows 8, Windows Phone 8 and BlackBerry 10. Now that most of the major operating systems are covered, it’s time to start making minor enhancements to that support. With version 4.2.2, released today, it now supports iOS 7′s native game controller API. Apple decided to standardize controllers across iOS, making it easier for developers to build in gamepad support. It was also trivial for the Unity team to plug that API directly into its own standard Unity input API. For more details you can check out the Unity developer blog. […]

[…] create countless titles for iOS and other platforms, got a 4.2.2 update that the company announced via its blog on Friday. Among the changes is support for game controllers in iOS, according to […]

[…] pretty major development in the wacky world of MFi Controller news materialized today as Unity announced on their blog that their forthcoming 4.2.2 update will include iOS 7 Controller support. The blog post covers […]

[…] games working with game controller support also work without it – on-screen controls continue. Unity’s release includes all the buttons you could possibly want to map […]

[…] Unity’s announcement that the latest version of its gaming engine supports iOS 7’s built-in controller scheme, the […]

[…] The Unity game engine likes to take things in small steps. First it was adding Linux and Wii U support. Then Windows 8, Windows Phone 8 and BlackBerry 10. Now that most of the major operating systems are covered, it’s time to start making minor enhancements to that support. With version 4.2.2, released today, it now supports iOS 7′s native game controller API. Apple decided to standardize controllers across iOS, making it easier for developers to build in gamepad support. It was also trivial for the Unity team to plug that API directly into its own standard Unity input API. For more details you can check out the Unity developer blog. […]

[…] The Unity game engine likes to take things in small steps. First it was adding Linux and Wii U support. Then Windows 8, Windows Phone 8 and BlackBerry 10. Now that most of the major operating systems are covered, it’s time to start making minor enhancements to that support. With version 4.2.2, released today, it now supports iOS 7′s native game controller API. Apple decided to standardize controllers across iOS, making it easier for developers to build in gamepad support. It was also trivial for the Unity team to plug that API directly into its own standard Unity input API. For more details you can check out the Unity developer blog. […]

Please also update the Social API, to work with Google Play Games, Windows Phone Games Hub and the Game Center new api.

It’s great that Unity is including this as part of there Input class.

But if you want complete control. Our IOS SDK Pro plugin supports analog buttons. You don’t need to poll to get controllers, we will send you an event. You can get the inputs as part of your game loop or register events. Basically, we expose all the IOS APIs for Game Controller. The documentation and API is available at http://www.u3dxt.com

Am I right that there is no support for the pressure sensitive buttons that the Apple API supports? I’m not sure if all controllers are required to have pressure sensitive buttons but the Apple documentation clearly states that you can get a number between 0 and 1 inclusive for reading how much pressure is applied to any button.

Hope this comes soon if it’s not already implemented and I’m missing something. Please let me know if I’m missing something! :)

I’m not sure that anything is “worth checking every several seconds”. Unity should relay events for this purpose.

Great! Thanks.

Supposedly, MFi controllers will also work with Macs via Mavericks. Will coding iOS controllers as above also provide the same functionality to Mac builds? Hope so! (And I hope we see these mythical controllers at Apple’s event this month.)

Comments are closed.