1
\$\begingroup\$

First of all this question is gigantic but it's mainly about Unity, maps, pathfinding, and real data.

The problem.

In my game the player sees the map of a real city (in 2D), it’s exactly the same kind of view you have on Google Maps. The map is “almost” real, as I will probably have to modify some street names, point of interest, or exclude some streets. But the fact is that it’s based on a real “big” city (think of Paris, France or London, UK), with too many streets or roundabouts. The player knows where she is and can travel throught ways / streets in a car (no pedestrian ways, parks, forests... are useful here).

I need to display itineraries to the player. At some point she will be able to say “I’m on Foobar street and I want to go on Blah street.” and I must show her several possible itineraries (at least 3 when possible).

The restrictions.

  • The game is made with Unity 5.X
  • Game must be playable on Windows/Mac/Linux
  • Game will probably, at some point, be playable on smartphones / tablets
  • Being connected must not be mandatory
  • More than 5 frames per seconds would be appreciated :)

The tricky questions.

  • How to embed an entire “real” city in a game?
  • How to compute itineraries?
  • How to display the map?
  • How to display the itineraries?

What I have in mind so far.

  • How to embed an entire city in a game?

Using SQLite.

SQLite is a database made to be embedded with software. After some researches it happens that SQLite can be used with Unity, however I haven’t tested for portability on smartphones / tablets. SQLite database can be used with a scheme called SpatiaLite. This scheme is made to help users working with GIS to save all the information they need. Also as OpenStreetMap.org offers some city dumps I have access to the city I want and can import it all in SQLite. After that it’s all about making the right request to know where a specific street or a specific point of interest is.

  • How to compute itineraries?

To be honest I still don’t know. I don’t know what SQLite can offer on this topic, but I’m sure someone, on the dark side of the Interwebz has already answered this.

Also, maybe a texture showing the "walkable ways" could be used alongside the database for pathfinding purpose. A simple A* or Djikstra on it could do the trick...

  • How to display the map?

2 options here. Either I generate meshes to draw EVERY streets of the map using SQLite data at runtime (meh… the CPU will burn), or I can use a tile system (it’s how map systems usually work). The trick with a tile system would be to be sure that the coordinate of the tiles match the coordinates of the information in the database. Tools like TileMill can export a set of tiles for different zoom levels.

  • How to display itineraries?

So, let’s say that I find how to display the map correctly. Let’s admit that I find how to compute itineraries based on the database. And let’s say that everything works like a charm. I can’t figure the best solution to display itineraries… Generate meshes based on DB data points and display them directly on the map? Won’t it be overkill? I don’t know.


Well now you know has much as I do.

My question is simple: how would YOU do it? Forget the method I have in mind right now, if tomorrow someone would ask you to answer this problem, what solution would you go for?

THANKS A LOT in advance for your time and your help.

\$\endgroup\$
  • \$\begingroup\$ Will your game be online? If yes, you can do many things on a server, which open new possibilities. On the opposite... We have to think more. \$\endgroup\$ – Aracthor Sep 24 '15 at 13:56
  • \$\begingroup\$ @Aracthor unfortunately, as said in the restrictions, I can't afford to ask players to be connected all the time. \$\endgroup\$ – lvictorino Sep 24 '15 at 14:00
  • \$\begingroup\$ "How to display itineraries?" How about you do what Google (maps) does? Or any GPS? I don't think you need to over-think it, as other experts laid the path for you :) \$\endgroup\$ – Vaillancourt Sep 24 '15 at 14:18
  • \$\begingroup\$ Hey @AlexandreVaillancourt thanks for your comment. I don't ask about the look to give them, but really how to render them technically speaking :) \$\endgroup\$ – lvictorino Sep 24 '15 at 14:42
  • \$\begingroup\$ As you said, this is a gigantic question. And it's mostly about technology choices. Those types of questions are off topic here. We can't tell you what to use, but if you tell us what you're doing and where you're stuck, we can help from there. I think you'll have to put a bit more work into deciding what to use and ask smaller questions about the details. \$\endgroup\$ – MichaelHouse Sep 24 '15 at 15:37
1
\$\begingroup\$

I think you have effectively 2 options to create all the roads/buildings : by hand (openstreetmap give you all the different waypoint coordinates), or download tiles directly from an api like a mapbox/osm server.

Apparently you want to have access to all the city, maybe you can use the bounding box from osm API

http://wiki.openstreetmap.org/wiki/Bounding_Box http://wiki.openstreetmap.org/wiki/Xapi#Query_Map

It gives you all the informations (positions of each buildings walls, waypoints, and a lot of informations) for an area given (and let s say for a city). You save all the differents buildings/roads in the database (why not), save only the informations needed. Now I think you need to cut this through tiles. For a tile you need somehow to take the right buildings/roads/...

Take in the db the right tile you want (and maybe the bordered tiles), And create it in 2d (here some polygon triangulation for the buildings (cutting ears algorythm or whatever), the buildings may be oriented clockwise or counterclockwise, you need to take caution of this when you will set the vertices point to unity. And some other triangulation for the roads). Load other tiles when you user quit the actual tile.

For itineraries, you saved all the waypoints roads, so you can use them as pathfinding waypoints with some A*/Djikstra, I think that should do the trick, and when you compute the actual tile you need to save somewhere(in the information of a road waypoint for example) that this list of waypoint is an actual path to render it as you want in the world.

Hope my point of view helps.

\$\endgroup\$
  • \$\begingroup\$ Hey thanks for your answer. The problem is that I would not be able to actually "edit" the data if the tiles are made from existing OSM data, and not my modified data. Also the bounding box technique is cool, but, I guess, it depends of the zoom level you're using. \$\endgroup\$ – lvictorino Sep 25 '15 at 6:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.