From the course: Unity: Integrating GPS and Points of Interest

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Calculate distance using GPS

Calculate distance using GPS

And in order to do this, I want you to make sure that you've downloaded the resources for this video. Now the resources are in a video pack called Pack3, Now the resources are in a video pack called Pack3, so that's what you need in what. I've got mine here already, so I'm just going to drag this into the and meters of the Earth. Okay, so this is for the months. Then what it does is it works out using a sphere and using Pi divided by 1/18 to return a radian and the difference. Now all we have to do is call this function CalcDistance. Passing in, the latitude and longitude of our current destination, our current location, sorry, and the latitude and longitude of the destination. What this will do is then return back the line below and what this does is it accepts a little parameter at the end, so we're passing through once more, once it's done it the first time, it then calculates it with the Earth radius in miles here, now, down here, we have also worked out the distance in kilometers…

Contents