Unity Community |

Hello, I tried to get latitude and longitude coordinates from 'Google Nexus One' and I failed.
I used the LocationInfo struct, but I think there is something missing. I wrote an Update function attached to 'GUI Text' like this:
void Update()
{
float lat, lon;
LocationInfo li = new LocationInfo();
lat = li.latitude;
lon = li.longitude;
guiText.text="LAT= "+ lat +"\nLON= " + lon;
}
Always returns 0.
Any idea? Thanks in advance,
Joel
The GPS location info is currently not supported on Android.
Ok, thanks for the response.
So, can I get GPS location info with a plugin using the NDK (or SDK) libraries from Android SDK?
Joel
Yes, by using the Java LocationManager interface (Android Dev Guide: Obtaining User Location) and a thin native wrapper between C# and Java, it shouldn't be too hard. But we will of course add this property, most probably in the very next release.
Hi,
We have been trying to create a plugin + bridge to read GPS Location at school.
We have run into a problem which is the following:
Using Unity 3.1.0f4, we cannot get Java plugins to work.
On Unity 3.0, we can run the (self-built using cygwin) example Java Plugin project, but get the following error in 3.1:
"Unable to find javabridge" (where javabridge is the name of our DLL, as used in the example, libjavabridge.so)
This problem occurs only on 3.1.0 for the Example project and for both 3.0 and 3.1 for our own created GPS Plugin.
Is this a known problem in the recent version of Unity and/or might there be a common mistake we are making? Like: would this error occur when we have a faulty C++ bridge?
This problem would of course be solved if we can use GPS directly in Unity, so please do your best!
Did you account for the (3.1) re-arrangement in the Unity Plugin directory layout to put Android plugins under Assets/Plugins/Android (ie not only Assets/Plugins/)?
I did not, will try it now. Thank you!
Ok, I now screwed up my SDK install, will need to try at a later stage, sorry and thanks again.
Does anybody managed to obtain the GPS Location from Android already? If yes, could you please post some instructions on how to do this?
GPS is supported in Unity 3.2 which is in alpha/beta state currently. But if you cant wait then the Android Developer Guide explains it in detail.
Hi!
I successfully implemented an GPS plugin for a client of mine, which in turn asked if anyone would be willing to buy it here for about 100$.
I can't decide to give it away for free, I'm sorry.
From release notes in Android section for 3.2:
"Implemented Location Service (GPS/Wifi)."
Lots of questions
Have anyone tried the GPS functions in 3.2? I guess it now should work with LocationInfo? Does it work with compass as well? Any js examples on how to work with it? This might open up for some layar type features!
There is a small example in the docs: iPhoneSettings.StartLocationServiceUpdates.
Visit http://www.enterra-inc.com/techzone/...es-on-android/ - probably will be helpful for your case.
Does anyone know if LocationInfo or GPS/WiFiGPS works on Android yet? I've been getting 0's through this very simple guitxt update (both with loc reference declared in Update, and currently in Start)
<code>
var gtxt:GUIText;
var loc:LocationInfo;
function Start(){
loc = new LocationInfo();
}
function Update () {
//Debug.Log(loc.longitude);
gtxt.text = displayLoc(loc.longitude, loc.latitude, loc.altitude, loc.horizontalAccuracy, loc.verticalAccuracy);
}
function displayLoc(lon:float,lat:float,alt:float,ha:float, va:float){
return lon.ToString()+", "+lat.ToString()+" @ "+alt.ToString()+" | "+ha.ToString()+" "+va.ToString();
}
</code>
It's a bit misleading that the only way to start location update is to call iPhoneSettings.StartLocationServiceUpdates(); ... even on the Android.