2D Top-Down MMO - Question about tiles

Hello all.

I’m thinking of doing a project where I re-create a game some of you might know; Tibia. For those who don’t, please check out a few screenshots.



http://www.gamershell.com/static/screenshots/13432/295188_full.jpg

I’ve gotten started on the project, and I’m thinking of designing it all from scratch. In order to start really working on the ‘game’ itself, I need 3 things.

1. I need a tile map.

Now, I’ve seen a couple tutorial videos on tile maps, but I’m still not sure what the best way is. In my opinion, I’d just make a series of quads, for example 10,000x10,000 for the first floor, and above that, another floor of the same size. My concern is that loading all of this would be a huge burden on memory or performance, even though all you had is quads with textures and transparency. Should this be a concern? Do i need to use a large plane instead? Or is there a way I can have map of 10k x 10k and only have a player load the 100 tiles closes to them, in each direction, and then load more as they move?

2. I need to edit the map

I need to be able to stack sprites on top of each other to create the classic Tibia map. I was thinking it would be easier to tie this functionality into the game, where I could essentially design the map from within the game. For example, you click on a location, it places a quad, you pick a texture, you pick a stack height (its position above or below other tiles/quads). Or does it make more sense to design a map editor outside of the game?

3. I need to load and save the map

Again, I’m not sure how to do this. Of course I could just create a text file, or an xml file and save values to it, and load them back. For example, at tile 0,0,0 there is a tile with sprite 11345 and on top of that is a tile 11297, etc etc. But I’m worried about performance, and efficiency. Also, how does this feature tie in with the map editor? Could I load and save the map from within the game?

I’d appreciate any help in understanding these concepts. Thank you for taking the time to read.

Second time posting a question, and I still haven’t had any replies. Is help really this scarce on the Unity forums?

I don’t know Tibia, but screenshots show it’s a 2D game. Unity is optimized for 3D, so making 2D games needs some special attention. There are toolkits in Unity Asset Store made specifically for creating 2D gameplay. Take a look and see how they work and what they do. Probably you’ll have to use some techniques they use if performance is concern. Maybe it’s easier/faster/cheaper to just pick one of such toolkits and build a game on top of it. If you can afford to wait, then next Unity version 4.3.x has many new features that make creating 2D games much more easier. They talked about it at previous Unite.

If you want to start now and not use any toolkits, then maybe these thoughts help you get started. I have to say, that some people here might want burn me alive for this advice, but you need to get to know Unity a bit more before we could dive into, say, writing shaders that do efficient tilemap drawing. Taking the most straightforward approach is probably the best way to start.

First off… do you really need 10kx10k maps? Even if you store one byte to hold tile texture id in it, it’s 100Mb per map. Also if there’s max, say, 40x40 tiles on screen at any time, then an easy calculation shows that if you want your player to experience each “screenful” of your map for 1 second, then it takes 17.4 hours to experience the whole map! But if you absolutely must, then that requires special attention.

One way of creating tile mapped levels is just to use snap to grid and build your levels from 1x1 quads. Place all the quads on XZ plane and use Y direction for creating separate layers. Upper layers use transparent material. While this can easily be the worst performance wise and probably will become tedious to create bigger levels, its a start. There are tricks to avoid performance issues with this approach from the start and also to some extent you can post-optimize scenes built like this. That’s a whole big topic on its own. Some keywords are: texture atlases, material sharing, dynamic/static batching, manual mesh combining, special shaders. To overcome placing invidual tiles, you can write editor scripts that import tile data from files or let you brush tiles. If you go for external tilemap editor, then first search what is out there before making your own. Maybe you can import images where color channels contain tile data. If you build a map inside Unity Scene view like this, it is all saved inside a scene file and there’s no need for you to manage loading/saving map data. The whole scene setup is a big topic on it’s own, because you’ll have tilemap, player sprites, enemy sprites, items, some UI, maybe some effects, sounds, user input, saving/loading, camera setup, lighting setup, etc.

To be honest, it’s easier to create “modern” games with unity than recreating “retro” games, because the tools today are not tailored for old school stuff. But of course you can make old school games too with a bit more effort.

Aaaand… as for MMO part, forget it for now :slight_smile:

That’s most likely due to the fact that what you asked for cannot be explained in a simple forum post and would require hours of tutorials to teach you how to do this. I will, however provide you some simple answers.

  1. make it smaller. MUCH smaller. 10,000x10,000 is 100,000,000 quads. Try making it 100 times smaller, even 200 times smaller.
  2. 2d in unity is mostly done with textured 3d planes and an orthographic camera. To put one sprite on top of the other, simply move it closer to the camera. Not sure about the rest of your question.
  3. if you make it smaller it won’t be a problem saving them with any of the methods you have mentioned. The problem is trying to save and load 100,000,000 quads.