Unity3D -- Send message to other mobile phones in the same vicinity
Asked Answered
L

6

6

Say we have a group of 10 people, within 20m of one another. Each person has a mobile phone (iPhone / android / Windows phone).

And one person taps the screen to send a message.

And this is instantly registered by the others. Synchronisation is the key. It has to hit all target devices within a few milliseconds.

How might I go about this?

  • web sockets: I can't see this working as there is not guaranteed to be any Wi-Fi network. maybe I set up one phone as an access point, and the others connect to it?
  • Bluetooth: maybe?
  • Audio: maybe, speed of sound is probably close enough time resolution. But messy.
  • Anything else?

I'm working in Unity3D, although since it allows mobile plug-ins I could implement separately per platform.

An iphone-only solution would still be of interest.

EDIT: Please don't just say 'Use Bluetooth'

EDIT: One way to rephrase the question: is it possible to set up a bunch of mobile phones so that UDP packets can be sent between them? (Ad-Hoc networking?)

EDIT: Links: Transfer NSString between two devices via bluetooth in iOS Transfer data between iOS and Android via Bluetooth?

Leprosy answered 2/12, 2013 at 15:7 Comment(3)
I'd say bLuetooth is your best bet. Another option would be a server side solution using GPS coordinates, but I don't think you can possibly hit the few milliseconds mark with that.Lucio
bluetooth seems to be the way to go.Treed
WiFi direct (or WiFi P2P as it is sometimes known) is an option.Tampere
G
0

for android, 'WiFi-Direct' will do this perfectly.

for iphone, 'Multipeer Connectivity' may be what you want.

i am an android developer, not very familier to iphone. and as far as iknow, Wifi-Direct use wifi, Multipeer Connectivity use Bluetooth.

and, iphone can connect to android WiFi-Direct soft ap.

hope this will help.

Golliner answered 13/1, 2014 at 4:14 Comment(0)
D
0

with OSC you can broadcast to all devices in the same wifi network in realtime.

haven't used it in a while with unity, but this might help: https://github.com/jorgegarcia/UnityOSC

Doghouse answered 17/1, 2014 at 14:15 Comment(0)
A
0

This will require some experimenting, but if you can connect the phone as a peripheral to one device, and as the master for another device at the same time, you can build a ring network, where all data is transmitted to all phones.

Honestly though, you should just connect to a wifi network (router). Unless the purpose of your project is build a work around network architecture. I am assuming using the wifi hotspot feature won't work on an off-the-shelf iphone with out it being jail broken. On top of that, the API for doing such a thing doesn't appear in the documentation.

Good luck though, if you do come up with a way to do this, would be great to hear about it.

http://en.wikipedia.org/wiki/Token_ring

Actinia answered 17/1, 2014 at 23:20 Comment(0)
E
0

Not sure if the "milliseconds" synchronization is feasible, but for the cross platform discovery part you can use an SDK such as http://p2pkit.io that abstracts all the complicated workflow behind discovering nearby devices.

Disclaimer: I work for Uepaa developing p2pkit for iOS and Android.

Ecbatana answered 4/5, 2016 at 14:37 Comment(0)
T
0

Use UNET make a dedicated server running UNET and a chatroom for locations, based on geolocations.

Thorn answered 4/5, 2016 at 15:9 Comment(0)
J
-1

The audio solution seems like a very unique technique. I can not say I have ever heard about going about it in that way, but seems legit. The only problems are that it could lose accuracy due to microphone quality. I did some research and found a way to play sine/square wave sounds in c#(assuming your not using javascript for unity). Heres an example for playing them:

    int sampRate = 10000;
    short[] buf = new short[10000];
    double ampl = 0.25 * short.MaxValue;
    double freq = 5000;

    for (int s = 0; s < buf.Length; s++){

        buffer[s] = (short)(ampl * Math.Sin((2 * Math.PI * s * freq) / sampleRate));

    }

As for getting the sound and validating it to see if its a match, I'm stumped, thats where my knowledge ends, but I know its possible, but might take more work than its worth.

To answer your main question, the easiest method would be bluetooth.

Jhvh answered 11/1, 2014 at 3:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.