0

I have seen custom fantasy world or game maps using OpenLayers or similar tools. Now say I want to do exactly that, but I also want to include the in-game traveling options. I imagine it being much like how Google does paths, walk to X, take boat to Y, walk to Z and the like.

Except in games there are other limitations and options. Like instant teleportation to specific points (think fast travel from anywhere), static connection between fixed fasttravel points, one way fasttravel options. And some travel options being locked behind a certain feat in the game (can't fly until you reach X point in the game) Ideally you'd also take speed of modes of travel into account, so the map can evaluate the quickest path between A and B.

I can't imagine there is a map out there that supports this out of the box or even remotely close to it. But if there were, it would provide support for a wide selection of games. Does anyone know if there is anything like it?

  • A cost surface is a cost surface, so a transporter pad has zero cost to one or more other locations when available, and infinite cost when not. Modeling multimodal transportation is tricky, though. – Vince Dec 20 '19 at 11:58
1

Assuming you do not need any additional geodata this can be done with pure JavaScript and any Web-Mapping software as the base (for instance OpenLayers, Leaflet, Mapbox GL). It requires quite a bit of coding of course.

Take a look at some of these very basic ol examples:

https://openlayers.org/en/latest/examples/feature-move-animation.html?q=line

https://openlayers.org/en/latest/examples/flight-animation.html?q=animation

Basically, in-game-traveling is nothing else than moving one feature (with a marker) from one position to another, maybe with an animation.

Once you need geodata (like a DSM for hills and mountains, waterbodies as polygons, etc) things become a lot more complex, but also interesting.

If you want paths like in a street network you need a real routing with a routing engine. For that you need a network and a routing software. If the number of paths is limited, you can create your own client-sided routing engine with something like a dijkstra-algorithm, if you want a real giant open-world game you will probably need server sided routing, and this is going to be a hell of a project.

  • It is actually to calculate routes. Sorry if i was unclear on that. I think the parts done by foot are hard to calculate because they are basically a per square ingame thing in my case. Worst case you could still just assume you can go over everything with 1 to 1 cost. And then use quick travel points in the same way but with like near 0 cost compared to the walking parts. But actually adding this to one of the map types, would just require me to write the whole travel system myself? I can't just use a game map, define "roads" and have it figure itself out with existing road travel tools? – Smileynator Dec 20 '19 at 15:48
  • I haven't looked deep into the software, but npmjs.com/package/dijkstrajs looks promising for routing on the network (you of course need a valid network for that). I think your game probably wants compound routing, first a raster routing to your network (keyword: cost path: wiki.gis.com/wiki/index.php/Cost_Path_Analysis), and then the classic routing on the network (e.g. with dijkstra) – Rob Jan 2 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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