Unity 4.0 iOS GPS Fix

Hello,

I’m at Leaping Coyote (www.leapingcoyote.com) right now, working on an iOS game that uses GPS. It looks like a bug crept into Unity 4.0 that gives bad values for the GPS data. If you’re seeing the same thing, here is how to solve that:

open up iPhone_Sensors.mm
Look for the code that calls UnitySetLastLocation. Notice how the timestamp is the last parameter? It should actually be the first parameter. Here is the rewritten section:

// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
		   fromLocation:(CLLocation *)oldLocation
{
	gLocationServiceStatus.locationStatus = kLocationServiceRunning;

	UnitySetLastLocation([newLocation.timestamp timeIntervalSince1970],
                         newLocation.coordinate.latitude,
						 newLocation.coordinate.longitude,
						 newLocation.altitude,
						 newLocation.horizontalAccuracy,
						 newLocation.verticalAccuracy);
}

Cheers.

Thank you so much for that! :slight_smile:

Hi, I have the same issue…I checke with the file but the timestamp is already at the right place…but I installed Unity 4 only yesterday so they fixed it maybe. Anyway I still have my GPS coordinates totally wrong :(, any other solution?

thank you so much for figuring this out! this was killing me. I could tell something was shifted because I was getting an expected longitude in the latitude parameter but never would have figured out what was off.

I confirm that this is fubar in the shipping version of 4.0.

Robin, are you sure you checked the calling code and not the code that defines the function?

Did the GPS bug get fixed

Yes, with Unity 4.0.1.