Search Unity

Question Send variables over wifi?

Discussion in 'Multiplayer' started by JudahMantell, Sep 3, 2020.

  1. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    So, I'm making a game for VR on my PC, and want to have an android companion app so non-VR players can interact with the game on the same wifi network, but I have no idea what the best way to do this is.

    All I need is to be able to send basic variables (Vector3 and Quaternion, possibly just split up into floats, if that's easier) and strings (to call functions on the PC) from the android device to the PC--no need to spawn prefabs anywhere (like what Mirror tries to do).

    Only those two devices should be connected, so I don't need complicated rooms or anything, and I want this to be as simple as possible, I don't like the idea of having to mess with a router just to get this set up.

    All tutorials out there are of two instances of the same application. This won't work for me because the two apps are completely different. (The android app will literally just be some UI elements, buttons, etc.)


    Is this possible? If so, what's the best way to do it? Bluetooth?

    Thanks! :)
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'd take a look at available networking solutions to see if any fit your requirements. I'd start here.
    https://forum.unity.com/threads/wha...of-available-network-solutions-assets.609088/

    High level networking API's for Unity typically have both the server and client running the same scene. That won't work for you, so instead I'd look at low level options. If your other app isn't even Unity, you may instead need to just use the Socket class.
    https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket?view=netcore-3.1

    Sorry I don't know if VR has any specific networking requirements, and don't know anything about bluetooth. Though I've seen some bluetooth assets on the Asset Store you could investigate. Networking should work fine without router hassle if you put the two devices on the same subnet.
     
  3. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    I'll definitely check that out, thanks!
    VR doesn't have any requirements, I was just sharing that for context.