- Home /
Radius around GPS location
Hi, I'm using the GPS on Android/iOS to find the players location and want content to show based on where they are. However, rather than putting a pair of very specific lat and long numbers, I want it to work if they are within a certain radius of a centre point, for example:
If the player is at 'this' GPS location or within a 10 meter radius, do something.
Can anyone point me in the right direction please?
This might be a bit overkill for what you're doing but take a look at $$anonymous$$otive.io. It has the functionality that you describe and more.
Answer by Bluk · Jun 01, 2017 at 09:47 AM
Hello,
I'm not exactly sure what you want to do but there is a few ways to do this (If i understood well). -If you want the radius to be an Ingame radius, you can just use Physics.OverlapSphere or Physics2d.OverlapCircle depending on your game to see if a player is within a radius of a specific point.
-If you want to compute the actual real world distance, you can use something like this: https://stackoverflow.com/questions/365826/calculate-distance-between-2-gps-coordinates to compute it.
Your answer
Follow this Question
Related Questions
How to enable location dialog? 0 Answers
GPS stuck on Initializing 0 Answers
Does Input.compass.headingAccuracy ever return everything but 0? 0 Answers
AR + GPS location based object/ collider 2 Answers
Keep unity running when minimized on iOS and Android 2 Answers