Unity3d location services not updating regularly

Hello to you all,

Im a bit a noob programmer so i hope someone can help me with this. I am trying to create a script so that I can get my walking speed with an android device using the GPS but Input.location.lastData does not update as regularly as it does with other GPS apps on my samsung so im thinking it has got to be my script. When walking it won’t update my location even after 5 minutes of walking outside with clear skies, when driving it would update the location a few times. Has anybody had this kind of issue? Below is my code.

 1. #pragma strict 
 2. 
 3. var tim;
 4. var Lat;
 5. var Lon;
 6. 
 7. function Start () {
 8.         // First, check if user has location service enabled
 9.         if (!Input.location.isEnabledByUser)
 10.             return;
 11.         // Start service before querying location
 12.         Input.location.Start (5,5);
 13.         // Wait until service initializes
 14.         var maxWait : int = 20;
 15.         while (Input.location.status
 16.                == LocationServiceStatus.Initializing && maxWait > 0) {
 17.             yield WaitForSeconds (1);
 18.             maxWait--;
 19.         }
 20.         // Service didn't initialize in 20 seconds
 21.         if (maxWait < 1) {
 22.             print ("Timed out");
 23.             return;
 24.         }
 25.         // Connection has failed
 26.         if (Input.location.status == LocationServiceStatus.Failed) {
 27.             print ("Unable to determine device location");
 28.             return;
 29.         }
 30.        // Access granted and location value could be retrieved
 31. 
 32.  function Update ()
 33. {
 34.   Lat = Input.location.lastData.latitude;  
 35.   Lon = Input.location.lastData.longitude;
 36. }
 37. 
 38. function OnGUI()
 39. {
 40.   GUI.Label (Rect (10, 70, 1000, 1000), "Lat : " +Lat);
 41.   GUI.Label (Rect (10, 100, 100, 20), "Lon : " +Lon);   
 42. }

Default value is 10 meters.
updateDistanceInMeters - the minimum
distance (measured in meters) a device
must move laterally before
Input.location property is updated.

http://docs.unity3d.com/ScriptReference/LocationService.Start.html


EDIT: I tried your script above. I set
the desired accuracy to 1 metre, I set
the update distance to 0.1 metres. I
went outside for a wander… As soon
as my device picked up the satellite
my location updated slightly under
Once per Second. Device : Xperia Z - GPS-only mode

Using Wifi and Network, the device
would begin updating once a second,
then stop for a while, and at some
undefined time would begin updating
again at 1/s.

Switching DEVICE WIFI OFF (So just Network), the figures updated just fine, switching WIFI back on made it stop.

The problem is WIFI LOCATION not functioning correctly. Your router doesn’t know where it is and its interfering with the network location, in this mode.

Looking at this page suggests that selecting DECLINE to Googles wifi location data collection may render WIFI positioning unusable.

You can always write a plugin to access the device GPS readings directly: Unity GPS plugin development tutorial: building a Android plugin for Unity with Eclipse and Ant | Matthieu Deru - Mat-D.com