question

brendan avatar image
brendan asked

Using geolocation in games

Question from a developer:

I want to make a game that uses geolocation, specifically for the purpose of letting players interact with players in their area. What's the best way to do this? How can I save the player's longitude and latitude and use that in Cloud Script to find players in the same area?

Matchmaking
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

PlayFab provides geolocation info for player in the login event, allowing that to be used for player segmentation. Using that, it would be technically possible to create a number of segments containing only the set of players withing a certain region. In that model, you would cache the information on the number of players in each segment periodically (perhaps once an hour) in Title Data, allowing the player to query it from there.

However, I suspect your needs are more sophisticated that this. If you want to do:

. Regular updates of player position (minute by minute updates)

. Open query of the data table to determine the closest players in realtime

Then you would need to use an external data store for this. The PlayFab data tables are not available for open query, as that's the most common way that titles run into issues as they go to scale (queries that appear performant at low scale may not be at high concurrency). Also, Cloud Script is intended for relatively lightweight, short-lived operations. So, attempting to aggregate information for a large number of users isn't really something you can do in Cloud Script.

We'll be providing more services around geolocation in future updates, but in the short-term, I'd have to recommend using external data services for something that will require high frequency updates and open query against the set of all players.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.