Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Android Bluetooth Multiplayer

Discussion in 'Assets and Asset Store' started by ZimM, Jul 1, 2013.

  1. Marrt

    Marrt

    Joined:
    Feb 7, 2012
    Posts:
    488
    @legitplayer09

    Since you asked in my inbox how i made this plugin work:

    1. At first I simply copied all objects from the scene in Demos/Unet/BluetoothMultiplayerDemo into my scene and checked if it worked when deploying to an actual phone

    2. Then i added some values i needed to have synced into "protected override void Update() {" residing in "BluetoothMultiplayerDemoGui.cs"

    Now you should have the default GUI and should be able to sync some things, from there you can start building your network stuff.
     
  2. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    There are no demos for NetworkLobby, because nothing really changes in this aspect compared to using UNet without Bluetooth. The only difference is that you must use AndroidBluetoothNetworkManagerHelper class to call StartHost() and StartHost() instead of calling them on NetworkLobbyManager directly. I've never used the Unity's Network Lobby asset, but it seems like the only script you need to modify is LobbyMainMenu. Take a look at the BluetoothMultiplayerDemoGui demo scripts to see how host and client are started there. Everything else should "just work".
    Do not edit the AndroidBluetoothNetworkLobbyManager script, otherwise it will be overwritten when the plugin is updated. Instead, create a new script and inherit from AndroidBluetoothNetworkLobbyManager. Otherwise, your idea is generally correct.
     
  3. legitplayer09

    legitplayer09

    Joined:
    Sep 27, 2016
    Posts:
    9
    @ZimM @Marrt thanks guys for the reply. Helped me out a lot!

    I was able to use Unity's Lobby with this asset with just few changes.

    I can share how I did it if you like, just leave a message.

    Thanks again Zimm and Marrt!
     
    Marrt likes this.
  4. SweatyChair

    SweatyChair

    Joined:
    Feb 15, 2016
    Posts:
    80
    Seems nice plugin!

    Would definitely buy it if it support iOS in the future!
     
  5. hengineer

    hengineer

    Joined:
    Mar 18, 2013
    Posts:
    11
    Hi, great plugin!
    Is there any way to broadcast a small amount of data during the discovery process? Similar to NetworkDiscovery.broadcastData in the Unity HLAPI?
    What I'm looking for is a way to automatically determine which server to connect to if more than one is discovered. So I'm hoping to include a short (maybe 16 bytes) data string with basic info like: number of players connected, public/private flag, etc.

    It seems like the alternative is to just try connecting to each discovered server in turn, receive a message with this data, disconnect, and move on to the next one in the list. But this sounds pretty inefficient.
    Any suggestions?
     
  6. hengineer

    hengineer

    Joined:
    Mar 18, 2013
    Posts:
    11
    Another question: in the RequestEnableDiscoverability method it says if you pass 0 for discoverabilityDuration then it will stay discoverable "forever" until disabled manually. Is there a way to disable discoverability manually without disabling Bluetooth entirely and then re-enabling it?
     
  7. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    Not in this plugin, but I am preparing a separate iOS plugin for release. Stay tuned!
    I've done some research, and it doesn't seems there is a way, unfortunately. The Bluetooth protocol has no support for some kind of "discovery info".
    There is no way to disable discoverability. This is a limitation of Android API. As a workaround, you can do another request with 1 second discoverability period. In any case, passing 0 for discoverability duration is highly discouraged, you really shouldn't do that until you absolutely have to.
     
  8. lorenzodom

    lorenzodom

    Joined:
    Apr 3, 2015
    Posts:
    20
    Hi, i recently buy this asset and i have some questions:

    I whant to modify some gameObjects propertys(color, text,etc) from one app to another, i could use the "Basic Multiplayer" model?
    I need to connect two different apps, they are not in the same unity project...so they need to have the same UUID?
     
  9. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    Both apps have to use UNet to communicate, but sure, you can do that. Except that since those are different apps, you won't be able to use built-in synchronization, and instead you'll have to use low-level message.
    Yes, in order to communicate over Bluetooths, both apps need to have the same UUID.
     
  10. lorenzodom

    lorenzodom

    Joined:
    Apr 3, 2015
    Posts:
    20
    Hi ZimM

    Is there any way to initialize the server without launching the authorization window to access bluetooth?
    I'm making an app for Samsung GearVR and I just want to launch the app in server mode, is this possible?
     
  11. lorenzodom

    lorenzodom

    Joined:
    Apr 3, 2015
    Posts:
    20
    I just commented the line "AndroidBluetoothMultiplayer.RequestEnableDiscoverability(120);" and that do what i need, i just need to make sure that the device have the bluetooth active before launch the app.
     
  12. lorenzodom

    lorenzodom

    Joined:
    Apr 3, 2015
    Posts:
    20
    Hi
    Im getting this error when i try to compile my app(Unity5.5 +GearVR utilities_1.10.0+ vuforia + AndroidBluetoothMultiplayer):
    "Unable to merge android manifests.See the Console for more details. See the Console for details"

    Console:
    CommandInvokationFailure: Unable to merge android manifests. See the Console for more details.
    C:/Program Files/Java/jdk1.8.0_91\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

    stderr[
    ]
    stdout[
    Warning: [Temp\StagingArea\AndroidManifest-main.xml:2, C:\_Personal\_UnityDemos\SmSGearVr01\Temp\StagingArea\android-libraries\AndroidBluetoothMultiplayer\AndroidManifest.xml:3] Main manifest has <uses-sdk android:targetSdkVersion='22'> but library uses targetSdkVersion='24'
    ]
    exit code: 1
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.HostView:OnGUI()
    -----------------------
    I guess the problem is the android:targetSdkVersion?
     
  13. gregori11

    gregori11

    Joined:
    Feb 15, 2017
    Posts:
    1
    Hi ZimM,
    I've been trying to connect two android devices and send data between them, but I'm not sure if RPC it's the only way to do it.
    I'm develping a turn-based game and I need to send from an android device a couple of variables to the other device without using RPC. There's any way to solve this?

    Thank you.
     
  14. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    Looks like you don't have Android API 24 support installed in your Android SDK.
    You can use any method you want, Android Bluetooth Multiplayer imposes no restrictions on that. If you only need to synchronize a few variables, you can try using SyncVar:
    https://docs.unity3d.com/Manual/UNetStateSync.html
     
  15. dobrMAN

    dobrMAN

    Joined:
    Mar 18, 2015
    Posts:
    8
    Hi, iam sorry for my stupid question, but i dont understand, i need have separate network managers for bluetooh and LAN (for PC as example) modes?
     
    Last edited: Mar 24, 2017
  16. UDN_d7f2dec4-28ed-4e50-9878-6161239eef7e

    UDN_d7f2dec4-28ed-4e50-9878-6161239eef7e

    Joined:
    Jul 20, 2016
    Posts:
    1
    I have a problem integrating plugin in project with GooglePlayGamesServices. My app crashes.
     
  17. macrian

    macrian

    Joined:
    Oct 26, 2014
    Posts:
    2
    Given that bluetooth hardware supports up to 7 devices. How many devices does this support?
    For example, If I want to host a game on my phone, how many other people can connect to it?
     
  18. AndrewFromEkb

    AndrewFromEkb

    Joined:
    Oct 26, 2013
    Posts:
    3
    Hello, tell me, can I simultaneously transmit / receive data using bluetooth and wi-fi in one application?
     
  19. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
  20. finx

    finx

    Joined:
    Mar 31, 2017
    Posts:
    6
    Hello I bought this asset and I would like to know how to use it to connect a PC with a tablet for bluetooth since I run the scene of mueltra on both devices but do not connect.

    HELP PLZ! :(
     
  21. mbhagat

    mbhagat

    Joined:
    Dec 15, 2013
    Posts:
    10
    Hi,
    I am working with UFE project.
    I have bought your asset after reading that it works with UFE.
    When i extract your asset inside project I am getting ert
     

    Attached Files:

  22. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    That's an option. The only difference between the included BluetoothNetworkManager is that it auto-closes the Bluetooth connection when UNet connection is lost, you can do that yourself as well.
    How exactly does it crashes? Can you show the log? I can't help without at least some information from you.
    Plugin itself imposes no limitations on the number of devices. It depends only on the device and how good Bluetooth implementation is on it. But keep in mind, since all clients are connected through a single devices, it might quickly become a bottleneck if you are sending lots of data.
    Not sure what do you mean. UNet only allows a single connection to host, how do you plan to do that? You can, for example, have a multiplayer game over Bluetooth and download some files over WiFi.
    This plugin is strictly Android-to-Android, you can't use it with a PC.
    You should ask the developer of UFE for support, not me. UFE supports Android Bluetooth Multiplayer, not the other way around. Apparently, the integration in UFE has to be updated.
     
    Last edited: May 9, 2017
  23. mbhagat

    mbhagat

    Joined:
    Dec 15, 2013
    Posts:
    10
    Neither I am newbie nor its first I am buying any asset.
    I always read description before buying any asset.
    I have read your description before and you had mentioned that you support UFE. When you have changed description I do not know (might be after my feedback).
    So why it was the in the description ?
    When you put something in your description to increase sale of your item you can not take back step like this.
    I lost my 30 $ because of you and UFE .
    I do not need this plugin if you do not support UFE or UFE does not support you.I do not need for any of my other game because they are not two player game.
    Be honest with business !
     
  24. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    I never had anything related to UFE in the description. In fact, I never even knew about there was some kind of special Bluetooth support in UFE. Also, if you visit the asset page, you can see this "Version: 2.1.2.0 (Apr 26, 2017)". This is proof - on Asset Store, changing the description changes that date as well even if version number stays the same, so clearly I couldn't have changed it a few days ago. If you want, I think you can verify it to even older dates using Wayback Machine or Google Cache. There wasn't ever any mention of UFE. The only one I did found on the Asset Store comes from the "P2P Network (UFE Addon)", so perhaps you mixed it up:
    https://www.assetstore.unity3d.com/en/#!/content/71906
    I understand that you are frustrated, but I have nothing to do with the problem. Android Bluetooth Multiplayer plugin itself works great on its own, and I never mentioned UFE anywhere in the description. It is UFE which claims to have Bluetooth support, and it is in the UFE where Bluetooth support is broken, so I don't understand why are you accusing me, not the developer of UFE, who isn't keeping that support package up-to-date? Why don't you give You should contact the UFE developer and ask him for an updated version, it should be trivial for him to create an update. I, on my behalf, would be happy to assist you in case you'll have any issues with Android Bluetooth Multiplayer itself.
    I hope the situation is clear now.
     
    Last edited: May 11, 2017
  25. Oryck

    Oryck

    Joined:
    May 16, 2017
    Posts:
    1
    Hello everyone.

    I'm currently using this plugin on a Bluetooth turn based game. The thing is, at the end of a match, i show an ad, so the Android activity changes and the connection is lost between the devices. I want the game to have an option to rematch, but i can't keep the devices connected when the ad is shown. There's any way to keep the connection on or try to reconnect them automatically after the ad is closed?

    Help please!
     
  26. mbhagat

    mbhagat

    Joined:
    Dec 15, 2013
    Posts:
    10
    Fact is I do not need it if not supported !
     
  27. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    The Bluetooth connection shouldn't be lost, it is independent from activities. Are you sure you are not stopping the connection on your own? Another possibility is that UNet connection gets lost, and then the Bluetooth connectivity gets dropped as well. In any case, sure, nothing stops you from implementing a reconnect.
    Please contact me via PM or email (contact@lostpolygon.com) for refund information.
     
  28. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    Good news everyone! I know a lot of you have been waiting for this for a long time, but the iOS/tvOS/macOS version is finally coming. It is now finished and will be out on Asset Store very soon. Check it out! :)
     
    Patico likes this.
  29. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    Aaand I'm happy to announce that Local Multiplater for iOS/tvOS/macOS is finally out! You can buy it here:


    If you want to try before you buy, send me an email or a PM, and you'll receive a fully functional evaluation version.
     
  30. Muhamad_Faizol

    Muhamad_Faizol

    Joined:
    Jan 21, 2017
    Posts:
    23
    Hi ZimM,

    I need your help regarding the purchase of your asset, and I've already emailed it to you.

    Thank you.
     
  31. Muhamad_Faizol

    Muhamad_Faizol

    Joined:
    Jan 21, 2017
    Posts:
    23
    Hi ZimM,

    I really appreciate your helpful support in solving my problem with regard to the asset. Looking forward to fully utilize this asset in my projects.

    Thank you.

    Cheers,
     
  32. qasem2016

    qasem2016

    Joined:
    Jul 31, 2017
    Posts:
    4
    hi . why OnStartLocalPlayer function not work when i use this plugin ? :(

    public override void OnStartLocalPlayer() {
    this.transform.tag = "Player";
    }
     
  33. qasem2016

    qasem2016

    Joined:
    Jul 31, 2017
    Posts:
    4
    why no one answer ?
    :mad:o_O:(
    i think its a bug
     
  34. djlee01

    djlee01

    Joined:
    Oct 13, 2017
    Posts:
    4
    hi i bought the basic version and import the asset into my unity project, and as I import it, there's these four errors(image). I don't know why and how to fix it. I suppose this is the bluetooth that works between unity game and android studio, I hope I didn't misunderstand this asset..
     

    Attached Files:

  35. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    Hi,
    the plugin itself doesn't interferes with UNet in any way. It is totally agnostic of networking system used. If for some reason that method is not called, this could only mean that the bug is in Unity or in your code.
    What Unity version do you use? Can you try import the asset into a clean new project and see if works there?
     
  36. djlee01

    djlee01

    Joined:
    Oct 13, 2017
    Posts:
    4
    The version I'm using is 5.5.2f1. And I tried importing into a clean new project and well I guess it works.. although I hit play and click the 'back' button that's on the game scene, there's that said(image). So... what should I do now?
     

    Attached Files:

    • err.JPG
      err.JPG
      File size:
      43.1 KB
      Views:
      53
  37. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    As the error message says, you have to add demo scenes to "Scenes in Build" in Build Settings. It should look like this:
    upload_2017-10-13_14-28-10.png
     

    Attached Files:

  38. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    Sorry hadn't noticed this right away. This asset is for multiplayer between different devices running the same Unity game. What do you mean by "bluetooth that works between unity game and android studio"? Android Studio is an IDE, it has nothing to do with Bluetooth.
     
  39. djlee01

    djlee01

    Joined:
    Oct 13, 2017
    Posts:
    4
    ok thank you, it works. But how can I apply this asset to my game with an android device? it occurs errors in the first place..
     
  40. djlee01

    djlee01

    Joined:
    Oct 13, 2017
    Posts:
    4
    oh, my mistake. I meant an android device.
     
  41. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    940
    It's impossible to say without taking a look at the project. Usually, the asset can be imported without any problems, but it seems like you are having some kind of conflict. If you want, you can send me your project privately, and I'll take a look.
    Just to clarify once again - the asset allows for Bluetooth multiplayer between Android devices for Unity games.
     
  42. franMx

    franMx

    Joined:
    May 27, 2013
    Posts:
    3
    Hi legit, would you please indicate which files did you modify?

    I've been trying to get the lobby working without much luck.
     
  43. franMx

    franMx

    Joined:
    May 27, 2013
    Posts:
    3
    With unity's network lobby example, added AndroidBluetoothNetworkManagerHelper component. It takes a bunch of clicks to start host as well as join. Has someone else eperiencedthe same issue?
     
  44. TheLorax

    TheLorax

    Joined:
    Mar 25, 2007
    Posts:
    86
    Hello! I need a bit of help/advice regarding this plugin. I can take any of the plugin demos, drop them on one of my Nexus tablets or Fire tablets, and they connect and handle multiplayer right away. However, if I load the same .apk on my Nvidia Shield TV or Amazon Fire TV...nothing works at all.

    What I would like to do is run the Shield TV or Fire TV as the server and connect tablets via bluetooth. Is this possible or has anyone tried on an Android TV device? Are there differences in hardware I just don't know about?

    Thank You,

    TheLorax
     
  45. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    519
    TL;DR How might this library's use of Bluetooth affect the DayDream controller (which uses Bluetooth to communicate with the phone)?

    Hi,
    I'm building a Google DayDream (and Cardboard) app and would love to allow local network play via Bluetooth using this app (I currently have UNet implementation).
    I guess best case situation would be the controller uses up 1 BT device so at most 7 other phones can be communicated with. That'd be fine. I imagine it'll mostly be 2 to 4 people at a time, mostly 2.

    Separately (since I'm writing), do you plan to allow the iOS implementation you mentioned you were working on to work with this one? (i.e. iOS and Android playing together over Bluetooth)

    Thanks in advance!