Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

GameKit Bluetooth + VoiceChat and AudioRecorder Plugins

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

  1. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    Our country can not visit the youtube site .
    can send to your video in to my email, thank you

    Sample video of Bluetooth in action.

    chuxiuxiang@gmail.com
     
  2. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    I just sent you an email with the video. Do you have access to sites such as KeepVid for downloading youtube videos over there?
     
  3. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    Your e-mail I have received
    But I also want to know GameCenter related video
    If so, please send to my email.
    I tried keepvid download, but can not download
     
  4. DavidPlans

    DavidPlans

    Joined:
    Jul 29, 2009
    Posts:
    39
    Hey Kenlem

    I'm trying to study the AudioRecorder plugin and was hoping to use PeakPower as you have, but not getting the same result...any chance you could share the script you used to explore this?
     
  5. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    I don't have the code on this machine but I'll dig it up later tonight.

    What are you seeing for results? Post your code and I'll have a look.
     
  6. Yann

    Yann

    Joined:
    Oct 20, 2007
    Posts:
    432
    Wow wow wow, really exciting products :D :D :D

    Would you consider developing a voicechat plugin for Unity desktop, too ?
     
  7. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    I'm kind of a mobile guy myself but desktop plugins aren't out of the question just yet....there are a bunch of iPhone plugins on the to do list though that need to get done first...
     
  8. Yann

    Yann

    Joined:
    Oct 20, 2007
    Posts:
    432
    Great to read, thanks for your answer. I for one would buy it - and I'm pretty sure many others would, too :D
     
  9. DavidPlans

    DavidPlans

    Joined:
    Jul 29, 2009
    Posts:
    39
    Well, I'm seeing squat for results, but I'm a n00b at Unity scripting so I'm sure I've made a mistake. Here's my current script:

    Code (csharp):
    1.  
    2. var Cube: GameObject;
    3.  
    4. function Start()
    5. {
    6.     AudioRecorderBinding.prepareToRecordFile( "myAudioFile.wav" );
    7.     AudioRecorderBinding.record();
    8.     Debug.Log( "RECORDING");
    9.     AudioRecorderBinding.enableMetering(true);
    10.     //how do I destroy the recording file? do I need to?
    11. }
    12.  
    13. function Update() {
    14.     var PeakPower = AudioRecorderBinding.getPeakPower();
    15.     Debug.Log(PeakPower);
    16.     transform.localScale.x *= ((PeakPower / -120) - 1);
    17. }
    18.  
    Now, this does compile ok and I can build the xcode project and run it on the iphone (iOS 4.1), and gdb seems to indicate values are there for peak power:

    Code (csharp):
    1.  
    2. RECORDING (Filename: /Users/build/builds/unity-iphone/iphone/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1719)
    3. -3.836922 (Filename: /Users/build/builds/unity-iphone/iphone/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1719)
    4. -4.394201 (Filename: /Users/build/builds/unity-iphone/iphone/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1719)
    5. -5.508759 (Filename: /Users/build/builds/unity-iphone/iphone/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1719)
    6. -6.066038 (Filename: /Users/build/builds/unity-iphone/iphone/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1719)
    7.  
    But the cube ain't scaling...so not sure what to do. I also tried transform.localScale *= ((PeakPower / -120) - 1);, as in, without the x axis...

    EDIT:

    Actually, changing the script's update function to:

    Code (csharp):
    1.  
    2. function Update() {
    3.     var PeakPower = AudioRecorderBinding.getPeakPower();
    4.     Debug.Log(PeakPower);
    5.     var scale = ((PeakPower / (-120)) - 1);
    6.     transform.localScale.x = scale;
    7.     Debug.Log(scale);
    8. }
    9.  
    I now get the same effect as you...but would still like to see how you did it!

    David
     
  10. Hoff

    Hoff

    Joined:
    Jun 20, 2010
    Posts:
    223
    Do _ALL_ of your plugins work with Unity 3 with iPhone BASIC? (I don't have Pro yet).

    Thanks!
     
  11. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Hoff, all plugins will work 100% with Unity 3 iPhone BASIC.
     
  12. Hoff

    Hoff

    Joined:
    Jun 20, 2010
    Posts:
    223
    Nice thanks!

    I just sent you a PM with another question.
     
  13. mehware

    mehware

    Joined:
    Nov 19, 2007
    Posts:
    739
    Just want so say thanks again to Prime31 and his Plugins.

    Viking Funeral 1.1 is out and includes a "Versus" mode using Prime31 Game Kit plugin. The mode is head 2 head with everything fully synced over wifi/bluetooth.

    A link to the game is here: http://bit.ly/a0po3d

    Since I got a batch of new promo codes I can give them out to some Unity Members. You must have a US iTunes account and have an iPhone4, iPhone 3GS, iPod Touch 3rd or 4th Gen to download and play the game!

    Thanks again Prime31... on to the GameKit plugin :)

    - Matt
     
  14. 22

    22

    Joined:
    May 22, 2009
    Posts:
    63
    Hi,

    I am using Unity3D for IPhone Pro 1.7 and Apple SDK 4.2. (.NET 2.1)
    After importing of the Prime31 GameKit, I get the following error:
    "The type or namespace "Touch" could not be find"

    The error occurs in the line 111 in the GameKitTestObject.cs

    Touch touch = iPhoneInput.GetTouch( 0 );

    Did anyone experience the same issue as me?

    Thanks
    Martin
     
  15. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @martdob, I believe the Touch class is called iPhoneTouchTouch in Unity 1.7.
     
  16. 22

    22

    Joined:
    May 22, 2009
    Posts:
    63
    I tried the class you suggested, but the result is the same. Does anyone know the right class name? Thx.
     
  17. 22

    22

    Joined:
    May 22, 2009
    Posts:
    63
     
  18. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    If rolling my own game lobby, is it intended that the peer picker appear? Am using:
    Code (csharp):
    1.     GameKitBinding.initializeSessionForOnlineOnly();
    2.     GameKitBinding.setAutoConnectPeers(false);
    3.  
    4.     // listening manually
    5.     GameKitManager.peerBecameAvailable += peerBecameAvailable;
    6.     GameKitManager.peerBecameUnavailable += peerBecameUnavailable;
    7.     GameKitManager.receivedConnectionRequestFromPeer += receivedConnectionRequestFromPeer;
    8.  
    Also, is there an event for displaying a list of active "hosted" games?
     
  19. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Joe, if you are rolling your own you won't have access to the peer picker. There is no way to get a list of active hosted games. GameKit just sets up a peer network and it is only aware of the connected and disconnected peers. It doesn't have the concept of an actual game.
     
  20. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    @Prime31 / Mike
    Ok thanks. In the case of client-server context, what can the server see? connectedPeers? (presumably)

    Then what can the clients see? The same? Is the server just another peer?
     
  21. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Joe, the picker will show different things based on the way you configure it. If you just call GameKitBinding.showPeerPicker( false ), the user will not get to choose online vs nearby. If you call GameKitBinding.showPeerPicker( true ), the user gets to choose online or nearby.

    If you connect multiple devices with one being a server and the others being clients the server will broadcast its identity and clients will search for broadcasted sessions. If you set the device as a peer, it will do both.
     
  22. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    For client-server; which call sets the server to broadcast and which call sets the client to listen? Check the docs for "broadcast" and saw no results :( Or is it automagic?
     
  23. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Joe, it's all automagic. Once you set your session mode (server, client or peer) using GameKitBinding.setSessionMode then call GameKitBinding.initializeSessionForOnlineOnly you are all set. Your server will broadcast and clients will search for the servers session.
     
  24. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Nice! Cheers for the tips Mike :)
     
  25. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Unsure if this is specifically related to the GameKit plugin, though am not seeing the behavior with projects that do not use the GameKit plugin.

    Every time I build a project using GameKit plugin in Unity => XCode for iPhone4 (default device), it works fine, but when I click Stop in XCode switch the Active Executable (in Overview) to iPhone3G device (both devices connected simultaneously) and Run or Build Run, XCode crashes hard with the following error:
    Code (csharp):
    1. Uncaught Exception:
    2. -[PBXDebugScriptCommand debugSessionDidStart:]: unrecognized selector sent to instance 0x200f5a6c0
    3.  
    4. Stack Backtrace:
    5. The stack backtrace has been logged to the console.
    and Console spits out this:
    Code (csharp):
    1. 2010/09/30 10:42:57 [0x0-0x63d63d].com.apple.Xcode[93112]   Xcode(93112,0x1197db000) malloc: reference count underflow for 0x201711d20, break on auto_refcount_underflow_error to debug.
    2. 2010/09/30 10:44:51 Xcode[93112]    [B].scriptSuite warning for class synonym in suite 'XDPluginSuite': [/B]'parentEntity' is not a valid class name.
    3. 2010/09/30 10:45:21 Xcode[93112]    -[PBXDebugScriptCommand debugSessionDidStart:]: unrecognized selector sent to instance 0x200f5a6c0
    4. 2010/09/30 10:45:21 Xcode[93112]    An exception was thrown during execution of an NSScriptCommand...
    Doesn't happen if the app is already built (i.e. when rebuilding from XCode, not from Unity), nor does Clean All change the outcome.

    The only work-around have found is if i Quit XCode and relaunch; can then Run on iPhone3G without XCode crashing.

    Find it super annoying as testing GameKit multiplayer requires both devices; quitting restarting XCode increases the already longer time between coding testing (Unity workflow has spoiled me! haha)

    Has anyone seen the same? What more, is there a fix? :)
     
  26. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Joe, that definitely looks like an Xcode bug and if you can reproduce it I highly recommend sending a bug report to Apple. I get that occasionally as well for both Unity and standard iOS apps but I could never reproduce it.
     
  27. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    @Prime31 / Mike
    Following the docs other posts in this thread, am attempting Server / Client and custom lobby but am seeing errors. Have GameKitManager on it's own object, and another object with a simple GK test class.

    Here's the relevant portion of the test class:
    Code (csharp):
    1. var connectedPeersGUIContent : Array = new Array();
    2. function Start() {
    3.  
    4.     // listen to all events for illustration purposes
    5.     GameKitManager.peerConnected += onPeerConnected;
    6.     GameKitManager.peerDisconnected += onPeerDisconnect;
    7.  
    8.     // init for custom lobby
    9.     GameKitBinding.setAutoConnectPeers(false);
    10.  
    11.     // Manual picker related events.  Required if creating online (WiFi) only session with autoConnect set to false
    12.     GameKitManager.peerBecameAvailable += peerBecameAvailable;
    13. }
    14.  
    15. function OnGUI () {
    16.     GUILayout.Space(64);
    17.     if (GUILayout.Button("Server", GUILayout.Height(64), GUILayout.Width(128))) {
    18.         GameKitBinding.setSessionMode( GameKitSessionMode.Server );
    19.         GameKitBinding.initializeSessionForOnlineOnly();
    20.     }
    21.     if (GUILayout.Button("Client", GUILayout.Height(64), GUILayout.Width(128))) {
    22.         GameKitBinding.setSessionMode( GameKitSessionMode.Client );
    23.         GameKitBinding.initializeSessionForOnlineOnly();
    24.     }
    25.     for (var someGUIContent : GUIContent in connectedPeersGUIContent) {
    26.         if (GUILayout.Button("Connect to Peer: " + someGUIContent.text))
    27.             GameKitBinding.connectToPeer(someGUIContent.text);
    28.     }
    29. }
    30.  
    31. function peerBecameAvailable( peerID : String ) {
    32.     // If autoConnectPeers is false, this is where you can prompt to connect to the peer or display it in a
    33.     // lobby list.  You can call GameKitBinding.connectToPeer to initiate the connection
    34.     Debug.Log( "peerBecameAvailable: " + peerID );
    35.  
    36.     var someGUIContent : GUIContent;
    37.     someGUIContent.text = peerID;
    38.     connectedPeersGUIContent.Add(someGUIContent);
    39. }
    After pushing the app to 2 devices, when both are up, i tap Server on one, and Client on the other. Either device spits this out in XCode debug console when tapping:

    Code (csharp):
    1. -> applicationDidBecomeActive()
    2. 2010-09-30 16:20:25.482 test[821:307] BTM: attaching to BTServer
    3. 2010-09-30 16:20:25.590 test[821:307] <<< Session >>> +[GKBluetoothSupport _determineBluetoothStatus]: BT not available - try again later.
    4. 2010-09-30 16:20:25.835 test[821:307] ############# didChangeState: Available, sessionMode: 1, isAvailable: 1
    5. 2010-09-30 16:20:25.846 test[821:307] BTM: posting notification BluetoothAvailabilityChangedNotification
    6. peerBecameAvailable: 1132865489
    7.  
    8. (Filename: /Applications/buildAgent/work/68355d6e5d19d587/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 2535)
    9.  
    10. Program received signal:  “EXC_BAD_ACCESS”.
    And nothing else happens :( BT is enabled on both devices (BT icon is grey on Springboard prior to launch)

    What is missing here?
     
    Last edited: Oct 1, 2010
  28. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Adding, the results do not change whether Wifi or Bluetooth are enabled. Thought I'd understood from your previous post that if one or the other is disabled, something specific would happen.
     
  29. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Update:

    Seems this is actually working, but the delay on finding a peer was >1min; found out by accident having taken a call just after setting it up.

    Is this delay something that can be mitigated? Seems odd to expect users to wait so long to play a quick game.
     
  30. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Joe, First up, there should be no difference between wifi or bluetooth. The Apple GameKit API hides the implementation details so you never know how you are connected.

    I have had some decent delays of over a minute and it appears to be semi normal from my experience testing with 3 devices. When I use client/server (as opposed to peer) connections do happen a lot faster though. If at all possible, using GameKitBinding.setAutoConnectPeers( true ) definitely speeds things up but it does remove the idea of having a lobby and letting the user choose the device to connect to.

    On a side note, do forum notifications work for anyone since the change? I don't get any notifications at all anymore and it delays my ability to get back to questions as they arise.
     
  31. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    re: connection time
    Interesting, have found the opposite: peer connections are near-instantaneous client-server is the mode taking over a minute consistently. Anyone else?

    re: documentation
    Wish in the documentation there was a clear disparate delineation of each supported mode, which methods need to be called which events listened to (and when), instead of the jumble of calls intermixed in the docs.

    To say, find that mixing peer client-server documentation is just confusing, especially given the differences between using the picker a home-rolled lobby how certain calls default to peer in specific cases.

    Similarly find the example code a big jumble of connection possibilities, and even now having isolated different types of connections, it doesn't show clearly how to setup a client-server model, what to expect when it works, when it fails, expected delays, etc. For example, in the demo, clicking Server on one device, then Client on the other, doesn't seem to do anything; probably is doing something, but it's not self-evident.

    Perhaps you consider such attention outside the scope of the plugin for the price of entry, but as a user, thinking such would make the plugin more accessible thus more likely to attract customers.

    re: notifications
    No, I didn't receive any; am going to toggle my subscription on this thread and see if that changes it. In any event, recommend posting any forum issues, either to Wish List or as a PM to a moderator.

    It's a great plugin to be sure (!), just finding it a bit unwieldy to use, different from the marketing message presented.

    In any case, hope this helps (assuming you're notified of the new post haha)!
     
  32. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    Just bought all your plug-in, but found that no one can unity3d 2.6 Pro iphone advanced 1.7 in normal operation.
    Found prefabs not open all the documents in, how do I try these plug-ins.
    Here are two plug-in game center and gamekit screenshots.
     

    Attached Files:

  33. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    @hxx2010
    Looks like the test project requires Unity v3; internal data formats (like prefabs) are not back-compatible with v2.x/iPhone v1.x.
     
  34. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    @Prime31 / Mike
    On the subject of custom lobby, in terms of user-flow, how is this supposed to go? For example:

    Player1: Chooses Host
    Code (csharp):
    1.         GameKitBinding.setSessionMode( GameKitSessionMode.Server );
    2.         GameKitBinding.initializeSessionForOnlineOnly();
    3.  
    Player2: Chooses Join
    Code (csharp):
    1.         GameKitBinding.setSessionMode( GameKitSessionMode.Client );
    2.         GameKitBinding.initializeSessionForOnlineOnly();
    Player1: sees a list of potential clients by watching peerBecameAvailable? what happens if this never comes? what should we trap for on errors?

    Player2: sees a list of servers by watching peerBecameAvailable also? same question about a list of other peers never showing up as above (right now have waited 5 min with the above code, and still no peers and no apparent means to check for it other than just assuming "if no peers within x time, call error msg")

    Player 2: picks a server calls connectToPeer()? how does the peerBecameAvailable event distinguish a server-peer from a 3rd-player-peer in the list?

    Player1: calls acceptConnectionFromPeer() on connectToPeer() from some peer? What if the server wants to wait for a 3rd player before starting?

    Etc.

    Does this scenario make sense? Indeed there are a lot of different ways one _could_ implement connectins, but the above is pretty standard client-server multiplayer connect flow.

    Delineating usage cases such as the above in your plugin documentation goes a long way towards integrating your code into our projects. Also, see Bill's Unity iPhone Enhancement Pack plugin documentation for a good starting reference.
     
  35. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Adding, given many Unity users prefer using JS for various reasons, it is probably worth mentioning in the plugin docs that any GameKit plugin-specific code must be in C#; unless that is not the case and am missing something else haha.

    Simply, wrote a test class in JS (with all the GameKit helper classes located in Plugins to account for Unity compilation order) and a duplicate in C# and the JS class doesn't seem to work at all; no specific error given in XCode, just seems events are not triggered if called via JS (likely due to the fact JS doesn't have events).

    Such this dependency is not obvious in actual use, as Unity doesn't bork on compile, and we naturally cannot test out the plugin in the editor... a few words at the start of the documentation would save wasted time for others.

    Hope this helps! :)
     
    Last edited: Oct 1, 2010
  36. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426

    @Joe, multiplayer with a lobby is a very complicated situation and it is so inherently flexible that there is no easy way to explain it. We purposely marked the documentation up with custom lobby warning text for this reason. You really need to have a firm understanding of the underlying Apple API's to get a full on custom lobby going. I highly recommend reading through their documentation to get the details of it all (you can of course disregard the code fragments because that is all done for you by the plugin). Unless you have a very good reason to make a custom lobby it is orders of magnitude easier to use Apple's built in picker.

    That being said with your example there are some things you have to manage when dealing with multiplayer async code as you have discovered. First off, if you never get a peerBecameAvailable message that is something your game will have to decide what to do. There is no error at this time so you have nothing to trap for. You could show a message saying "tell your friend to start the game" or you could stop listening after some timeout and show an error message.

    $Screen shot 2010-10-01 at 11.32.36 AM.png

    The image above should give you an idea on how to tell what the peer is (client/server) when the event is fired. The GameKit API just gives you the peerId and not the connection type but you can tell the connection type based on the currently set type. For example, if you are a client than when the event gets fired you can be certain it is a server because only servers broadcast their availability. Of course, this is only valid for client/server. If you are of type peer you are acting as both a client and a server.

    To wait for a 3rd peer all you need to do is have the server accept the first connection. That will get you 2 devices connected and ready. If a third device shows up, the server can accept that connection and then broadcast a message to start the game.


    Edit: as the marketing states you can quite literally connect 16 iDevices with one line of code:

    Code (csharp):
    1. GameKitBinding.showPeerPicker( false )
    It truly doesn't get any easier than that. This is multiplayer programming which is often thought to be some of the most difficult out there and the plugin handles a ton of details for you. Choosing to add a custom lobby (as the documentation states) is adding quite a bit of complexity to the coding for your game. You now have to manually handle all the cases the plugin normally handles for you. It is a tradeoff: super simple approach using the built in peer picker or full control over everything with a custom GUI.
     
    Last edited: Oct 1, 2010
  37. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Mike! Please don't take my critical feedback as detraction, the plugin is clearly awesome for what it does and have already recommended it to others :)

    Indeed there are many approaches possible, but it is still worth showing _common_ usage scenarios as seen in other multiplayer games; they do go a long way towards getting up and running... Beyond the fairly useless claim (sorry!) of "one line of code", as cool as that is; show me a game that has any meaningful player interaction with one line of networking code and I'll change my tune haha.

    We can of course blame Unity (haha); it does so much goodness in the background and presents it all so nicely, with useful demos, us users kind of expect the same out of our plugins. To say, am glad to know that I can set texture coordinates with a GL call in Unity, but usually prefer to just drag one on the texture slot of a material. Make sense?

    Thanks for answering my questions; hope the feedback on documentation rings through.
     
  38. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Am seeing unexpected weirdness creating a custom lobby context.

    Specifically am setting a server device to Server mode, a client device to Client mode, then populating a list of buttons of peers using peerBecameAvailable()...

    At this point, the client is showing a button for the Server ID (nearly instant now, woo hoo!), but when I tap on it, the client freezes with the button stuck halfway down!

    Here is all that I'm calling:
    Code (csharp):
    1.     public void OnGUI () {
    2.         foreach (GUIContent someGUIContent in connectedPeersGUIContent) {
    3.             if (GUILayout.Button("Connect to Peer: " + someGUIContent.text, GUILayout.Height(32)))
    4.                 GameKitBinding.connectToPeer(someGUIContent.text);
    5.         }
    6.     }
    7.  
    Upon calling GameKitBinding.connectToPeer() XCode immediately shows the error EXC_BAD_ACCESS msg (mentioned in a previous post) and the app freezes.

    Any idea what is going on here? Server is set to show a list of requests, but they never appear after the client freezes.
     
  39. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Getting similar "nothing happens" results setting up client server with the demo app.

    Can anyone confirm that client/server works?
     
  40. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Joe, to get a client server setup running using the demo scene do the following:

    - Device 1: touch "Set Session Mode Server"
    - Device 2: touch "Set Session Mode Client"
    - Device 1 and 2: touch "Show Peer Picker" and choose a type of "Online"

    You now have a client/server connection going and you can touch and drag your finger around on one of your devices and it will move the box on the other.
     
  41. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Thanks to confirm the process; that's working.

    Is there a demo showing a basic custom lobby connection working? Still seeing the client hang after server peer is shown on the client (as per above posts)

    Also, looks like forum notifications are working again! Woot! :)
     
  42. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Joe, there is no demo with a custom lobby but the process is nearly identical to the above process. The only difference is that instead of letting the plugin accept the connections for you they need to be accepted manually.
     
  43. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    @Prime31/Mike
    And the picker? Is that step still required or does
    Code (csharp):
    1. GameKitBinding.initializeSessionForOnlineOnly
    handle it?

    And should both client server call it after setting?
     
  44. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Joe, you can skip the picker by using the above mentioned method on both/all devices.
     
  45. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    @Prime31
    Indeed; yet am still seeing a crash when client tries to initiate connection with server.

    To aid debugging, have attached a very basic custom lobby example / repro package including scene, gamekit manager a test class (GameKit plugin will need to be installed for this to work)

    To repro:
    1) on 1st device (tested with iPhone4) tap Server
    2) on 2nd device (tested with iPhone3G) tap on Client
    3) When the server appears on client, tap "Connect To Peer: ####" on client.

    RESULT:
    Client crashes :(

    Can you repro this? XCode dumps a ton of useful info in the Organizer Console; have a look?
     

    Attached Files:

    Last edited: Oct 5, 2010
  46. SoapSupah

    SoapSupah

    Joined:
    May 14, 2010
    Posts:
    4
    First thanks for the plugin mate, I was getting crazy with all that objective-c thing since I could only activate the peerPicker, all the other things were buggy >.<..

    1 - I need to send a message only for a selected peer, like the first peer for example, and theres a function called sendMessageToPeers but it needs a vector of peers but i realy needed to send just one like this:

    Code (csharp):
    1.  
    2. function Start () {
    3. GameKitBinding.sendMessageToPeers(GameKitManager.connectedPeers[0], "LobbyController", "StartAsPlayerOne", "You start as player one okay?");
    4. }
    5.  
    2 - I was looking at the plugins and was thinking of doing one of those methods (send to the selected peer, or something like that).

    3 - I think mehware was asking for something like this but, anyways there we go:
    it is possible for me to check something like if (Myself == GameKitManager.connectedPeers[0]){ something here }
    in case yes, that eliminates the question 1 and 2.

    I will keep looking at the docs and codes to check if I skipped something..
    thanks again.

    Soap.
     
  47. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Soap, sending to just one peer is totally doable. Just do something like this:

    Code (csharp):
    1. GameKitBinding.sendMessageToPeers( new string[]{GameKitManager.connectedPeers[0]}, "LobbyController", "StartAsPlayerOne", "You start as player one okay?");
    It is also available in the test scene on the "Send Time to 1st Peer" button.

    Technically, you can't connect to yourself so your peerId should never be in the connectedPeer array.
     
  48. SoapSupah

    SoapSupah

    Joined:
    May 14, 2010
    Posts:
    4
    thanks for the info man, I tried something similar here.

    also I will post some results when its done, I will probably ask alot more about sending messages and things like that since we are developping an RTS title.
     
  49. Sam at FPS

    Sam at FPS

    Joined:
    Sep 1, 2009
    Posts:
    80
    Hey there Prime31,

    I've bought your plug-in. It looks really awesome. Exactly what I was looking for.

    But....

    I'm having some problems with it. Specifically X-Code linking issues.

    I get this *sometimes* even with the Test Project/Scene that your package comes with.

    Are there any steps that I am missing here:

    • I create a new project.
    • Import your GameKit package.
    • Add the 'GameKitManager' prefab to the scene
    • Add another object with script attached that uses the GameKitBinding stuff.

    What I am seeing is a "gamekit unity support successfully integrated" message pop up from Finder each time I build. Is that normal? Should it happen each time I build? It seems to halt the build process until I click 'OK'.

    I am using 'Build and Run' in Unity. But even when I just 'Build' then open in xCode and try to run it there I get these linking issues. With your test scene, if I Build and Run, it fails, but then if I build again in Xcode it works and I can run it.

    I'm using Unity 3, and the 4.1 SDK.

    In Player Settings I have
    • Target Device - iPhone only
    • Target Platform - armv6
    • Api comp level - 2.0 Subset
    • SDK version - iPhone OS 4.1
    • Target iOS version 3.0.


    Help me Obi Wan Kenobi, you're my only hope
     
  50. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Sam at FPS, the errors you are seeing are 100% because the files are not being copied. This can happen for a variety of reasons. First up, make sure the PostProcessBuildPlayer and PostProcessBuildPlayer_GameKit are executable. If they are not, make them executable either using Finder or by doing:

    Code (csharp):
    1. chmod 755 PostProcessBuildPlayer*
    I assume they are executable because they did work for you at least once. Next up is to make sure Xcode is closed when you click Build from Unity (dont use Build and Run). You should only see the popup notification the first time you build and when you do a Replace from Unity.

    Give that a shot and report back with your findings.