In this second part, I added a player character and 3D buildings to our cute little PokemonGo clone!
It’ll be a short post really. I used the Ethan model from “Standard Assets” package. All I did was importing the package, simple as that. It works with WASD controls at the moment as that’s the easiest way to navigate during development process but I implement GPS coordinate based movement in the future as well.
3D buildings was even in the previous package actually. I somehow forgot it in there but the building heights was set to zero so it was quite hard to notice it. Anyway I fixed the bug and the code itself for better looking buildings. Just better, not beautiful… but we’ll get there, slowly. Generation code is quite straight forward but still I’ll try to explain shortly.
As you know from previous post; CreateMesh() function in the Building class takes the building corners as a List<Vector3> called verts. Those vectors (coming from Mapzen Api), or lets say the polygon generated from those vectors, gives us the base of the building. What I did was, to generate that polygon in the air and use it as a roof. Then for every edge in the roof, I created a side wall down to y=0 and viola!
This yields quite simplistic, bare bone buildings as seen in PokemonGo. Should be enough for now but might give BuildR a chance in the future as well.
With character movement working, we have a new problem at hand; player can actually run to & fall off the map. We’ll fix that in the next post, by creating & loading new tiles dynamically as the player moves.
Hope you like it, Cheers,
Download PokemonGO Clone Part 2