Download

Some questions about making a world grid system

I am wanting to make a grid system that functions like the one used in Runescape. You can kind of see it in this http://imgur.com/a/nWssl. I want to support grids that are at least a couple square km’s, which I don’t think would be an issue if I keep the cell size 1m x 1m (is that too low res?).

  1. I am assuming it would be best to handle all of the basic grid logic in C++ for performance reasons.

  2. If I do use C++, what is the recommended type of storage that I should use? I see TArray’s used quite a bit but they are one dimensional. Of course I could use helper functions to simulate a 2D array but that isn’t preferred. I found this example from Rama https://forums.unrealengine.com/showthread.php?60398-Replicating-a-2D-dynamic-array&p=232520&viewfull=1#post232520 but it looks like that would replicate the entire array whenever there is a change instead of just the changed cell. Am I correct in that assumption? If so, I don’t think that solution would work well if the grid has a lot of stored actors.

  3. Would having a grid just for static objects like trees, walls, and water be better than a grid that holds both static and dynamic objects?

  4. I found this toolkit https://www.unrealengine.com/marketplace/advanced-turn-based-tile-toolkit and am curious if it would be easier to write my specific implementation from scratch or to modify the one on the market to be realtime instead of turn-based.

From these questions you can guess I am a noob. Is this task too difficult for a beginner like me? I feel like if I can at least get the foundation down for my game, adding content like items and mobs should be much easier. Some pointers and/or psuedo-code would be much appreciated!

Are you just looking for the visual style, or are you making a system which requires a literal grid with full access to it?

A movement system and way to access the actors at the grid cell so a literal grid. The visual side isn’t important although it would be nice to visualize it for debug purposes.

I’d say it really depends on what functionality you need for your world grid system e.g. determine what’s in the cell, determine neighbour cells, etc. In that regard your question wasn’t very specific so it’s hard to suggest anything without more details.
In general, depending on your needs you may not have to explicitly store and replicate each cell of the grid (where most of the cells will probably be empty most of the time anyways). Instead you could derive the cell number/index from the world position of the actors/components.

Food for thought, hope that helps you to some degree :slight_smile:

if you store your grid on the server, and run all ai stuff there (I mean executing orders issued by players on clients) replication won’t be a problem. Actor tile position can be replicated fine, and probably enough.
In my RTS project I use a 1D array with helpers for 2D (and 3D), it works fast, of course written in C++. I use more maps, a static and a dynamic one, what can be combined if needed runtime.
But a lot of systems related to pathfinding, movement, ai decision making really depends on your actual game.

I checked out your RTS project and it looks very cool! When you say that you used a static and dynamic map, do you mean a C++ map container? If so, why did you choose that one over something like vector? Also, could you provide me with some function names that you use? I am kind of overwhelmed atm and it would be nice to know what to implement. As for some clarification on my needs, I am looking to replicate the basic movement system and how I assume they store their map data. I think they store each actor in a grid cell and can have multiple dynamic actors share the same cell. That way you can’t have players block each other. As for the movement system, it looks like they are moving the player one grid cell at a time but the rendered movement looks smooth. I am planning on using a navmesh and using a map coordinate to grid coordinate function whenever I need to access the location.

I just call the containers as map (because its “scientific” name is map decomposition system), but indeed they are a set of 1d arrays of structs or simple types…

If you want to create a grid/tile system, instead of describing my huge code base, I really recommend you to read through this page, very useful: Amit’s Game Programming Information

Moreover, if you want to use navmesh, you can change navmesh settings to have a grid like resolution. In the 3rd part of MOBA tutorial at around 41:30 you can get the info: Blueprint MOBA Minion/Creep AI: Lane Movement & Navmesh Debug

Thank you very much for the links. I also remembered I had a book on game programming and it has a few pages on grids.