Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

GameKit Bluetooth + VoiceChat and AudioRecorder Plugins

Discussion in 'iOS and tvOS' started by prime31, Aug 29, 2010.

  1. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @paradoks, that *should* work. As long as the call males it from Unity to iOS it will be fine. iOS gives you some time to deal with being backgrounded.
     
  2. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    Can two different apps on two different devices be able to communicate through this bluetooth plugin? Thanks.
     
  3. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @apple, the apps that connect must have the same bundle ID. If you really needed to connect two different apps it would require changing one line in the source code.
     
  4. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    I am thinking of having an app acting as a game controller to another app. In fact, the reason I want it to be as separate app is because this game controller app can act as an input device to several different apps.
     
  5. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @appleunited, that would be entirely doable by just changing the one line that I mentioned.
     
  6. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    Great to know that. =)
     
  7. kiles

    kiles

    Joined:
    Apr 2, 2011
    Posts:
    9
    Where is the mentioned line? :)
     
  8. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Kiles, it appears there are two lines (my mistake): one for the "Online" type and one for "Nearby".

    Lines 131 and 327.

    The key is to manually set the SessionID to something (it doesn't matter what it is). Normally the bundle ID is used which is why apps can only connect to each other.
     
  9. kiles

    kiles

    Joined:
    Apr 2, 2011
    Posts:
    9
    Thanks!
     
  10. friuns3

    friuns3

    Joined:
    Oct 30, 2009
    Posts:
    307
    youtube video is down?
     
  11. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @friuns, search YouTube for "prime31studios" to find all our videos.
     
  12. racer161

    racer161

    Joined:
    Mar 2, 2011
    Posts:
    6
    Dear Prime 31,

    I'm working on a new project and i need the audio of one iDevice to broadcast to up to 5 others, this audio would not be just chat audio but anything (the final speaker output of the iPod). I'm on a budget, but if you could give me a quote , or if i could just modify the game kit, please let me know.:razz:
     
  13. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @racer161, transferring the audio from one device to 5 others is a really big project. There are no shortcuts that I can think of off hand and none of our plugins handle anything close to what would be required.
     
  14. racer161

    racer161

    Joined:
    Mar 2, 2011
    Posts:
    6
    Thanks Prime 31,
    If that isn't possible without a serious overhaul how about just audio inside the app itself, like everything from the audio listener itself?
     
  15. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @racer, it wouldn't be possible via the GameKit Plugin.
     
  16. racer161

    racer161

    Joined:
    Mar 2, 2011
    Posts:
    6
    Thanks Again Prime 31,
    Looks like I'm gonna need to find another solution. Thank you for your time!
     
  17. QQQ

    QQQ

    Joined:
    Feb 25, 2012
    Posts:
    2
    Hi,Prime31,my project want record player's voice to a sound file and send it to server ,then server send to another player. the whole process is not realtime, just like draw something. our project will support iOS/Android.
    my question is, does AudioRecording meet my require? I mean does AudioRecording can save player's voice to a file? and player the voice on another iDevice/Android?
    thanks!
     
  18. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @QQQ, the AudioRecorder Plugin will handle the voice recording for you. From there you can just use the WWW class to send it to your server. That would work just fine.
     
  19. QQQ

    QQQ

    Joined:
    Feb 25, 2012
    Posts:
    2
    Thanks! Prime31.
    does AudioRecorder support iOS? I found you category AduioRecorder only under Android.
     
  20. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @QQQ, we have an AudioRecorder Plugin available for iOS as well.
     
  21. kootenay

    kootenay

    Joined:
    Feb 8, 2011
    Posts:
    116
    This is very cool... maybe a dumb question, but I'm interested in adding bluetooth using this plugin and have a skier which is controlled via accelerometer/tilt controls. Would I be able to have 2 skiers on each screen, and allow each player to tilt to control their player?
     
  22. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @koot, you can send any information you want over the Bluetooth connection.
     
  23. kootenay

    kootenay

    Joined:
    Feb 8, 2011
    Posts:
    116
    Eeeeexcellent! :)
     
  24. irwin524

    irwin524

    Joined:
    Oct 13, 2012
    Posts:
    11
    With this plugin and Unity 3.5.x iOS Basic license, will the connection between 2 iPhones through the same Wi-Fi network be established? Even though iOS Basic does not support .Net sockets?

    Sorry if this is a silly question, because I am total newbie to unity and network stuffs.
     
  25. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @irwin, you can connect up to 16 devices with the plugin. All iOS plugins work with Unity iOS Basic.
     
  26. uno

    uno

    Joined:
    Sep 12, 2011
    Posts:
    3
    Hi,

    I am having some issue, i need some way to figure out distinguish connected player, so that they cannot move each other's game object.
    @prime31 did you figured out way to check some kind of client-server.
    please let me know.
     
  27. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @uno, the peerConnected event will fire with all connected peers. The getPeerId gets the current users peer Id.
     
  28. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    So I got a question.

    Lets say there are four people somewhere, and they are not on a local wi-fi network or anywhere near wi-fi.

    Will those four people be able to connect together via bluetooth to play a game? Or will something fail if a local wi-fi connection is not available? Will it limit it to something like 2 person peer-to-peer when only bluetooth is available?

    Also, in the absence of any wi-fi, can the host and client session modes still work?

    BTW I am interpretting 'local wi-fi' as meaning wi-fi through a bunch of devices connected to same wi-fi router. Is that correct, or do the devices connect directly to each other via wi-fi?
     
    Last edited: Jan 5, 2013
  29. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @tech, BT has a range of about 30 feet. Local wifi means all users are connected to the same router.
     
  30. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    What about the instance of four players? If there is no wifi router they are connected to, will the four players connect over bluetooth? Or will there be some issue?

    And what about mixed bluetooth and local wifi connections? Lets say someone is the server and two players connect to them via local wifi but the third isn't on the wifi network, could that person connect and play in the same game via bluetooth?
     
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @tech, as previously mentioned, Apple hides all implementation details of the networking. If you watch the logs you will see they fire up BT and WiFI using Bonjour but there is no API for you to ever know what antennae is doing the connecting.
     
  32. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Another question,

    Reading your docs it's not apparent to me how I make a host server for local wifi and bluetooth.

    I want one player to click a button that says 'Host game', then other devices ideally just automatically connect to that device via local wifi or bluetooth. So I don't want to use the peerpicker, as I assume that will just show all nearby peers, how will players know which one is 'hosting'?

    The only function I see to start session besides the peerpicker is:
    public static void initializeSessionForOnlineOnly()

    But I assume thats for OnlineOnly as the function states, is that true? Or can I call that function to make a device be open to all connections, even local wifi and bluetooth?

    Or can 4 devices connect to each other via the peerpicker somehow?
     
    Last edited: Feb 2, 2013
  33. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @tech, if you need to do client/server (not peer to peer) your only option is programmatic sessions using initializeSessionForOnlineOnly. The peer picker will work for up to 16 devices but only in peer to peer mode (not client/server).
     
  34. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    But if I do initializeSessionForOnlineOnly, that won't work over local wifi or bluetooth, correct?

    With the peer picker, is there anyway to make it so that the peer picker will only find one device? I'm not looking to do a true client/server setup, where I specifically set GKSessionMode to Host/Client as that disables bluetooth doesn't it? But rather I am rather trying to do a quasi-client/server setup where, 1 player will host, and the three other devices will only connect to that one host device via peer to peer method. From what I gathered this is the only way to do implement a quasi-host/client setup over bluetooth, as bluetooth only supports peer to peer GKSessionModes.

    But as I understand it the peer picker will just show all nearby devices when bluetooth is an option. So how could you get 4 devices hooked up locally via that method, where three devices are connected to 1 device?

    I don't want players to have to know who is the host and select them from the list, that just sounds like technical diffuculties for the user.

    I also want to do this quasi host/client setup over peer to peer because, if I understand correctly, if you were to do 4 way peer to peer through the peer picker, doesn't that mean each person would have to open the peerpicker 3 times? One time to connect to each other device?

    I'm looking in the actually Apple Docs for GameKit and have an idea for how to do this, but I don't see the relevant functions in your plugin. Or am I missing something? Will I need to implement a few new native functions into your plugin from GameKit to accomplish this?
     
    Last edited: Feb 2, 2013
  35. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Prime, does your function here:

    public static void initializeSessionForOnlineOnly( string sessionId, string displayName )

    call initWishSessionID from here:
    http://developer.apple.com/library/...Reference.html#//apple_ref/doc/uid/TP40008258

    ??

    If so, I don't see any mention in the Apple docs that signifies that initWithSessionID creates an 'OnlineOnly' game type, it seems like you should be able to create bluetooth host client setup via that method...
     
  36. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @tech, the name is legacy from the old name of the Apple API. Apple never lets you actually choose the connection type nor do they ever let you know what connection type is being used. That information is not important and their API will not let you know it.
     
  37. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Ok, thank you, I think I've read enough all over the place to get my mind wrapped around this.

    Once I get this functioning in my game I'll report back how I did it.
     
  38. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    I can't build GameKit plugin to the device. This is an error log when I tried to build the demo scene.

    I use Unity 4.0.1f2 and Xcode 4.6.1 This plugin still works with the latest version of Unity and Xcode, right? I don't know what causes the problem with this plugin because I can build Prime31 SocialNetworking plugin just fine. :???:
     
  39. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jjoby, When having issues with the build system you should visit our troubleshooting guide here: http://prime31.com/docs#iosTroubleshooter

    If the troubleshooting guide does not solve your problem please send us the plugin logs referenced in the guide.
     
  40. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    Sorry if it sounds like a dumb question. But isn't what I posted earlier a plugin logs?
     
  41. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    I think that I've already included plugin logs in my previous post. I will just copy paste here again so you can see it clearly.

    The plugin error is in bold line.
     
  42. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    OK. I really want to confirm if my GameKit plugin is up to date or not. This is really bugging me. What's the latest released date and version of GameKit plugin? It may sound stupid but I have reasons why I feel this way.

    1. In the Asset Store, the latest version is 1.1 on Mar 2012. It was released a year ago. But other Prime31 plugins in the Asset Store were just recently updated.
    2. I bought both Social plugin and GameKit plugin and I've read the documentation page. I notice that the project that has Social plugin has a menu Prime[31] in the editor and it has "update prime[31] tools" in the drop down list. The project that has GameKit plugin has a menu Prime31 (no []) and it doesn't have any update tools command in it. Furthermore, GameKit plugin doesn't have "P31RestKit.dll" at all.
    3. In the doc page, it said "all plugin updates since December 1st no longer have *Manager prefabs" But my GameKit plugin still has GameKitManager prefabs in it.
    4. In this link, user falkonragno had similar error logs like mine. Undefined symbols for architecture armv6: (although, mine is armv7) and especially plugin error logs "runner failed with error: [Errno 2] No such file or directory: '/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/'" which is exactly the same as my case. And the solution to solve this error was to update the plugin.

    These are the reason why I suspect that my GameKit plugin may out of date. Please answer me if the GameKit plugin (released on Mar 2012) in the Asset Store is up to date or not? If it's up to date then I really doubt that such old plugin is still compatible with latest Unity and Xcode. If possible, I also want to ask those who use this plugin. Does it still work with latest Unity and Xcode? I really want to confirm it or else I may not sleep well. +sigh
     
  43. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jjobby, running the "update..." menu item 2 times will get you all the latest build scripts and tools along with the new prime[31] menu.
     
  44. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    I really want to do that but just as I've already said. My GameKit plugin doesn't have that functionality. The Prime31 menu from this plugin only has three drop down list for plist configuration and open xcode. It doesn't have any update command. Or do you mean I can import both Social plugin and GameKit plugin in to the same project and use update in Prime[31] menu that comes from Social plugin instead?
     
  45. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    Thank you Prime31 for the updated version of GameKit plugin in Asset Store. But you may be too hurry to release it. There is an error in GameKitTestObject.cs You put #endif for #if UNITY_IPHONE in the wrong place. It should be inside of the class. Aside form that, it works now. I can build the plugin and able to connect two devices using bluetooth. Thank you again. :D
     
    Last edited: Mar 22, 2013
  46. unity-tiger

    unity-tiger

    Joined:
    Dec 10, 2012
    Posts:
    3
    @Prime31

    I have to implement multiplayer functionality in my game through bluetooth.
    It has two player player1 and player2.
    how to recognize players which one player1 and which one player2 and their turns.
     
  47. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    Hi, some functionality of gamekit bluetooth such as PeerPicker is deprecated in iOS7. When will you plan to upgrade your plugin?
     
  48. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jjobby, we will absolutely not remove deprecated methods. That would totally and completely break the plugin for iOS versions before 7. Apple deprecates methods/classes and doesn't remove them for at least 3 major OS updates in most cases.
     
  49. jpatinop80

    jpatinop80

    Joined:
    Jul 29, 2012
    Posts:
    55
    @Prime31
    Hi, I was trying to make it work the mohydineName's code, but unity sends me an error: GameKitBinding' does not contain a definition for `sendDataReliably' and I really don't know why? vould you please help me to solve this? thanks
    PD: I'm using ios7
     
  50. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @jpatin, lets start with the basics: did you open the GameKitBinding file and see the sendDataReliably? Did you check the documentation here? There is no such method. There is a sendData method that has a bool parameter called reliably.