- Home /
Native iPhone Bluetooth Multiplayer?
So I want to create a 2D Tank game that you can connect to another iPhone over Bluetooth and battle in a stadium. I have everything working, but now I just need to get the Bluetooth connection and I am at a loss. I have searched around and it seems that in 3.x Unity was supposed to get a native Bluetooth API, but apparently it didn't or if it did I just cannot find it.
If I could choose, I would rather not pay for it (I'm an Indie developer, not a massive corporation) and I would rather it be simply [i]Bluetooth[/i] connection - No GameCenter or OpenFeint, just simply connect over Bluetooth and play.
Just for the record -- in iOS/$$anonymous$$ac development the whole WiFi/Bluetooth thing is pretty annoying. (Or depending on how you look at it, is really great!) A lot of the apple systems are done so that there is "no difference" between Bluetooth and WiFI. Thus if you're just starting with networking on the $$anonymous$$ac/iOS and you use their "game kit" system (a beginner's networking library) you actually - and this is pretty frustrating - CANNOT TELL, OR DECIDE whether the user is using Bluetooth or WiFi. As a practical matter (i.e. by looking at logs), I think incredibly few games are ever played using bluetooth - everyone just has a WiFi hub somewhere these days. The bottom line is it's quite possible that you should just "forget about the issue" and when you have a sled working, you'll see it works either with WiFi or (if no WiFi available) with bluetooth. If you are already a $$anonymous$$ac developer you will know all this but it might help someone else reading in the future.
Well that would be fine - It doesn't really matter whether it's over WiFi or Bluetooth, all that matters is that there is a device-to-device connection and there is no connection with GameCenter, OpenFeint, Plus+, or another of the other game networks out there for iOS.
Hi $$anonymous$$enoites -- then you have no probelm. Just go ahead and start learning about Unity's networking system.
Are you new to network program$$anonymous$$g? if so, be prepared for plenty of learning. Networking is just plain hard. But Unity's system is about as easy as it gets. To be clear, you will never have to touch $$anonymous$$ac Networking, it is totally "automatic" and involves no program$$anonymous$$g.
Enjoy.
So I can use the Unity Network system (http://unity3d.com/support/documentation/ScriptReference/Network.html) and it will work for iPhone/iPad as well, or is it simply $$anonymous$$ac/PC networking only, and I have to use a plugin (Like Prime31's Plugin below) for iPhone/iPad networking?
Ah -- yes, ABSOLUTELY CORRECT. It is 1000000% iPhone / iPad.
In fact, I would say 999 out of 1000 times it is used by developers, it is used for iPhone/iPad networking.
(I wouldn't be surprised if it has NEVER been used for $$anonymous$$ac/PC ! :) )
So you're completely golden. By the way, regarding the "kit" mentioned below and similar. It is completely confusing to me what they are offering: no networking could be simpler than the Unity Networking system, so I'm not really sure what they are selling.
One guy on the asset store sells a system that is essentially "a really good and complex example of how to use the Unity Networking System." I don't really recommend it - just jump in and start learning about, as you say, the Unity networking System. Enjoy.
if you are BRAND NEW to networking program$$anonymous$$g, expect a learning curve. (I have no clue if you are a newbie or an oldie.)
All network program$$anonymous$$g is inherently difficult.
Just for the record: you may be wondering "How good is the Unity Networking System" -- that is to say compared to the difficult chore of writing absolutely native iOS networking code (presumably using - let's say - CocoaAsyncSocket and the like). In our opinion - it's very good indeed. You won't be disappointed. If you spend 12 months hand-crafting iOS networking code, and you're an El33t iOS developer, and you're a personal friend of Quinn, you can maybe get faster connections (I mean faster join-together time) but the actual efficiency of the networking is fantastical, it's great. Enjoy!!!!
Your problem is solved.
Answer by dannyskim · Jan 16, 2012 at 07:15 PM
I know you said you'd rather not pay, but Prime31's plugins for Unity are great and are affordable for an Indie studio. His GameKit bluetooth plugin for unity is only 50 dollars, which I believe is well worth it's weight in functionality. I haven't tried it personally, but if it's anything like his 5 other plug-ins i've bought, it should be relatively easy to integrate if you know what you're doing.
Quote from prime31.com and his plug-in for bluetooth:
Have you ever wanted to add Bluetooth or WiFi multiplayer to your game but didn't want to deal with the all the complexity of networking? Now you can add multiplayer support to your game in just one line of code! If you want to kick it up and notch and add voice chat it's just one more line! It is really THAT easy! Check out a simple example video here. For the adventurous types, the GameKit Bluetooth/WiFi and Voice Chat plugin gives you all the tools you need to make your own game lobby fully customized to match your games style!
Haha yeah, if I couldn't find a free one I was going to go with Prime31's Bluetooth plugin. It seems the best of the best plugins out there, and it seems quite simple to use. Also seeing as how a lot of the other Unity projects I am working on require a Bluetooth/WiFi connectivity as well, the $50 might just become chump change.
Thanks Danny :) Just wondering - Which of his plugins have you used and have been easy to work with? I was also looking into using his iCloud and possibly Store$$anonymous$$it but I really have nothing to go on for those...
I'm currently using his TapJoy, Store$$anonymous$$it, Free 2dToolkit, GameCenter, and Etcetera plug-ins. They've all been fantastic to use as long as you understand his usage of delegates, events, and actions and how to add your code into his base to tailor it to your project.
Trying to learn Objective-C then creating a wrapper for all of these plug-ins would have literally taken me 4 - 6 months, making the REUSABLE purchases of these plug-ins invaluable and a moot price point for me. That's assu$$anonymous$$g I make any money off my projects of course, =p.
Storekit was a breeze to implement after learning how to deal with the delegate and actions calls. The only thing that's missing from the Store$$anonymous$$it is the native access to the Apple Spinner to freeze the Unity thread when a transaction is communicating and being processed. This is included in the Etcetera plug-in separately, which is why I decided to purchase it.
Your answer
Follow this Question
Related Questions
Does Unity take care of unseen objects? 2 Answers
[Character Controller] Jump-Movement in other direction while beeing in midair 0 Answers
Is unity the way to go for a 2D game for iOS? 2 Answers
why unity IPA file size increased after installation as compare to unity APK? 1 Answer
Unity 5.0.1f1: iOS client to Linux server RPC silent failure 1 Answer