Representing Game Map as Singleton Entity

Hello. I’m implementing a map for an RTS game so I expect map size to go big, like 10k x 10k. I thought I’d use BlobArray to contain all grid nodes of the map (100 million nodes in this case). Nodes contain coordinates, walkability, terrain type, movement cost etc…

I also want to store Map as BlobAssetReference in a component of a singleton entity so all other systems can reach this easily for pathfinding etc…

But I can’t allocate this much since I’m getting “Length * sizeof(T) cannot exceed 2147483647 bytes” exception. So I have a few questions:

1- Is 100 million nodes too many? If so, how should I change my approach here?
2- Is representing big map data as singleton entity good idea?
3- How do I handle rebuilding the Map at runtime in this case? For example if player puts a building and a couple of nodes need to change their walkability, I have to create the whole Map BlobAssetReference from scratch, right?
4- Any other suggestions?

1 Like

Instead of a component, you could have a dynamic buffer of blobs at a resolution of 1k x 1k or something. This not only reduces the allocation size, but also means that rebuilding the blob would be cheaper.

Regarding (3), blobs are meant for immutable data, not mutable data. So unless the cost of rebuilding the blob is relatively infrequent enough that treating blobs to be immutable makes sense, you may want to consider a different data structure.

1 Like

You do realize you’re trying to allocate an array over 2GB in size right just for your map right? That just isn’t feasible for most games / platforms.

You definitely need to break it up (or better yet use an alternative to a grid, navmeshes etc).