unity3d mapzen pokemongo water layer

PokemonGo clone using Mapzen – Part 4: Water Layer

Welcome back to the fourth part; Water layer, Git page, bug fixes and more!

-First of all, I finally created a git page for our little PokemonGo clone! You can find the latest fixes and updates, file bug reports, post feature requests there. I’ll be using it extensively so have no worries or hesitations about post there as well.

-Then we have some bug fixes. Previous versions didn’t really work properly in different detail levels for example. New tiles positions were messed up as well. They should be all fixed up now but yea, didn’t had time to test it extensively so please do let me know if you stumble upon anything weird. You can also read commit logs for more, I’m trying to write everything down properly there.

-There is also a parameter for tile sizes now. As you may remember, tile sizes wasn’t controlled in previous versions which caused countless problems. i.e. Lvl16 tiles were 611 unit wide while Lvl14 tiles were 2446 unit wide. Now we have a “TileSize” property under the world script, scaling down/up everything to fit tiles into that width&height.

-Last but not least, we now have a working water layer! It was a little tricky as there are lots of “MultiPolygons” in the water layer but turns out it isn’t that hard after all. I just did some silly mistakes which confused for a while. It happens. Occasionally. Sometimes frequently. But yea, with that fixed, we have a quite smooth water layer now. I just put a simple blue polygon for water but you can put Unity3D water over that easily.

unity3d mapzen pokemongo water layer
Yes, that’s Istanbul for you! Looking good? Nope? Yeah….

Hmmm am I missing something? Well it’s all on Git now, you can check all commits and commit messages for more. You can also check GitHub Issues page for known issues as well. I’m actively adding stuff there as well.

And that’s it. I guess. Please do let me know what you think about it or have any questions. Your feedback is what keeps me going. And page hits, share it will you? Thanks!

Cheers,
Baran

Download PokemonGO Clone Part 4: Water Layer

40 thoughts on “PokemonGo clone using Mapzen – Part 4: Water Layer

  1. Why are you using a random height of buildings in the code?

    var height = UnityEngine.Random.Range(settings.MinimumBuildingHeight, settings.MaximumBuildingHeight);

    Many buildings in Matzpen are parameter height.

    {“kind”:”building”,”area”:2773,”sort_key”:475,”addr_street”:”Rector Place”,”height”:71.50000000,”volume”:198269,”source”:”openstreetmap.org”,”min_zoom”:13,”addr_housenumber”:”380″,”id”:277922715}}

    1. I always ignored that as like 99% of buildings in Turkey/Ankara doesn’t have it.
      But you’re right, I should have noted that properly as it might be useful for other people.

  2. Hi
    if you have a Gameobject in the Scene. How can you get the Lat/long of this object?

    Thanks for the answer.

    1. Hey Jay!
      Depends on the object really. Everything we create there actually comes from Mapzen json which provides the lat/long values as well. Which means you can simply keep those values inside any object you want (i.e building lat/long inside building.cs). I haven’t done this but should be fairly easy.
      Converting a random point inside a tile to lat/long won’t be that easy though. First you’ll have to find the tile containing that point, convert that to lat/long. Then you’ll have to calculate the delta position relative to that tile center and convert that to lat/long using the ratio of tile Width/Height to point position. Sounds complicated I know but I can’t think of anything simpler off the top of my head.

  3. Awesome work so far! I am eagerly awaiting a post on how to position an object within a tile based on it’s actual GPS coordinates, or have you already posted on that? Essentially I’m looking for how to place the character at the right position based off of GPS.

    Thanks again for your amazing work =)

    1. Hey Ken, thanks!
      I haven’t started the GPS thing yet, I have some other higher priority stuff like road meshes and merged meshes etc.
      I’ll try to get into that as soon as possible though, I know lots of people are waiting for that 🙂

  4. Hey, nice to see you are still working on it 🙂 I mentioned in the last post you made about myself working on bringing water into it. I just loaded up your latest build and noticed that water isn’t working properly either. Some streams/water based areas as I said seem to want to use the polyline instead of polygons. It’s pretty annoying!

    You defintely fixed the issue with the way the mesh is built though as that has fixed areas where it wasn’t rendering correctly. I am happy to create some screenshots of the water areas I am looking at if you need to see what I am on about.

    Cheers, and keep it up!

    1. Hey Maccu!
      Yes as you noticed I totally skipped LineStrings for now. Guess I can look into that in the future as well. Also can you post the lat/long you’re working on (or mail me) so that I can see&test the problem.
      I’m working on merged buildings&roads at the moment. Got it working but needs some more work, it’ll be great 🙂

  5. Hi!
    Sorry for my English! Google Translate 🙂

    Great job ! I’m also doing a similar task. But on Mapzen I learned from your blog 🙂 Some aspects of your work and help me , thank you !
    By chance you do not know whether there is in the incoming JSON object center tile come in geographic coordinates ? The latitude and longitude . (That I need for the correct location of objects )

    1. Hey!
      You mean tile center in lat/long? Hmm I don’t think Mapzen has that but I’m pretty sure you can convert tile coordinate to lat long. Have you checked the GM class inside this project?

      1. Yes , everything has turned out 🙂
        My inattention ) But before that, I had to stick to the devs Mapzen, and they sent the necessary formulas , which , as it turns out , there is already in your project 🙂

    1. Hey!
      Parks looks awesome, guess I’ll add that as soon as possible as well! Great work man, please keep posting your progress 🙂

        1. How are you making sure it stays within the boundaries? Are you just looking at min and max long/lat coordinates?

  6. Mapzen contain not all OSM tags in particular it does not have key is responsible for the color of the building: building: colour.

    I added the extraction of data through the API OSM for Way and Relation.

    But faced with a problem.
    The OSM Relation consists of Ways, and each may have their own Way unique keys than the other Way.
    Mapzen all Way included in the shared object.

    http://fenix-cam.ru/data/Screenshot_10.jpg

    1. Hmm I didn’t know about building color stuff. Looks interesting but I also don’t get what you mean by “ways”. Is it roads? Or something else?

      1. OSM has 3 types of data.

        Node – a point with coordinates.
        http://www.openstreetmap.org/api/0.6/node/326806790

        Way – the object consisting of the points (the parks, the roads, buildings)
        http://www.openstreetmap.org/api/0.6/way/422159731

        Relation – a complex object composed of different Way with different parameters.
        http://www.openstreetmap.org/api/0.6/relation/2470041

        OSM contains information about the color of buildings, material, shape of the roof, its color and size. more: http://wiki.openstreetmap.org/wiki/Simple_3D_buildings

        1. Aaah I see. Maybe I should look into OSM stuff in the future as well, I don’t know much about it at the moment.
          Thanks man!

    1. Merhaba Kadir. Beğenmene çok sevindim, umarım işine yaramıştır. Yakında çok büyük birkaç ek daha geliyor, çok daha güzel olucak 🙂

  7. Hi,

    Thank you so much for these tutorials, they are very helpful.

    I do have a question though.

    If I have the lat/long of the tile center, and the lat/long of a random point in the same tile, do you know of a way to calculate distance (X and Z in unity) between these two points in the tile?

    1. Hey Lily, gald you like it!
      I’m sure there should be a better way to do this but you can always convert those lat/long to meters and multiply with the scale factor of base world object. Can’t check it right now but that should yield the distance in “unit” I believe. Guess I’ll look into this in the future as well, getting lots of questions on that.

  8. no idea why the textures do not apply ? I changed the texture of the materials in the resource folder. But it does not work

    1. Hey Andres,
      I don’t generate UV coordinates for meshes at the moment, has to be that. No texture or anything will work without that, just flat material colors.
      You can try generating UV’s in mesh creation functions, that’s technically an easy problem but it’ll get messy considering various building types and city etc.
      Guess I’ll stick with flat color for a looong while 😉

      1. Alexey got a grass texture working in one of the comments above; would making everything a single game object break that now?

        1. Hmm I’m not sure but I believe he can make it work again with minimal effort. We have a landuse layer for parks now for example, you can use that mesh and generate grass on it no problem.

Leave a Reply