- Home /
Access android accelerometer via Wifi / 3g-4g
Would it be possible to access an android phones accelerometer data in near real-time from a standalone PC unity program via Wifi/LAN ... or even better : a Unity webplayer via 3g/4g ??
I was thinking to set up a client on the phone and server on the PC. I am in the process of learning network functionality of Unity now.
The SPECIFIC answer I look for is this: Would the above be possible WITHOUT the need for "the customer" to set up a server, open up data traffic for UDP, closing down firewall and stuff like that.
Just don't want to go through the process of creating a killer-app only to discover that it only works if my customers are computer savvy enough to set up a server.
Cheers, Jesper
Answer by Bunny83 · Dec 19, 2013 at 06:26 PM
Your description is confusing and contradicting with some of your requirements. Also it's missing the exact purpose. Who is the customer? (not which person, what does he get from you? where should it be run on? Is it a multiplayer "thing" / game or singleplayer?) What do you consider "setting up" a server? A server is an application that needs to be started in the first place.
Now some assumptions since i probably don't get all required information from the next post ;)
From what i can read it seems you want to create a PC game / application and use an Android device as remote control for the PC game / application. Generally it doesn't matter if you run your PC game as Standalone application or as webplayer application. The basic features of Unity work on all platforms.
If it's a singleplayer game you can simply open a local server and let your Android device connect to your game. If the device is in the same wlan as the PC you shouldn't have much connection problems unless the user has a strict firewall. However connecting from a 3g connection means the android device connects from the internet, i.e. from outside. Now it depends on whether your customers router does "support" NAT punchthrough or not. If not you can't connect if your customer doesn't port-forward your specific port.
As for the "near realtime", even on the Android device itself it's not realtime since the hardware runs seperate from your game and could have a lower sample rate than your frame rate. Network traffic always has latency, even when you have a really, really good connection it's still there.
As for the "firewall closing / configuration" that's the wrong way to process this issue. If your customer has an active firewall, it's his problem. All you can do is tell him that a firewall might cause problems. A firewall is made for causing problems for foreign applications. That's the one and only purpose of a firewall. It has to be configured by your customer, there's no way around this. If there was a way around, the firewall would be useless.
We live in a more and more complex and complicated world. You can't make everything idiot-proof. If there was a petition for the requirement of an "internet license" to be allowed to use the internet, i would sign it, any time.
Thx a lot Bunny,..
I kinda knew I was vague in the description because I lack knowledge in the network field, most program$$anonymous$$g as a matter of fact. But I learn as I go along and until now been quite successfull :) I know it must be a pain for all you REAL programmers... Thanks a lot for keeping up with me and others :)
You were quite successful in figuring out my needs. I want to use the android device as a controller for a bigger screen, PC or other. Although not in the traditional controller way... :)
... And you gave me the answer I needed. As long as it is inside a LAN it should work fairly easily. Via the internet it would be more difficult....
Is NAT punchthrough support common??
About the "real-time" I just meant decent for a controller. I know there will be delay.
All in all it seems I should focus on LAN/wifi... for now at least ;-)
Thx m8