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 - Unity Tutorial
From the course: Unity: Integrating GPS and Points of Interest
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Creating a Google Cloud live account9m 31s
-
App layout and scrolling menu buttons9m 22s
-
Project setup7m 18s
-
Create a scene controller13m 34s
-
Connect the GPS class to the place finder app11m 14s
-
Load data from a website URL, part 1 from inside Unity8m 43s
-
Load data from a website URL from inside Unity, part 29m 48s
-
Refactor code to improve functionality3m 56s
-
Process the JSON code from a URL11m 23s
-
Populate a virtual object with JSON data16m 1s
-
Use the real names on prefabs3m 31s
-
Calculate distance using GPS14m 27s
-
Dynamic button listeners, part 14m 16s
-
Dynamic button listeners, part 211m 54s
-
Sort results by nearest first, part 110m 12s
-
Sort results by nearest first, part 28m 43s
-
Sort results by nearest first, part 39m 56s
-
-