- Home /
Dungeon Keeper like game
I'm thinking about making a Dungeon Keeper (DK) like game using Unity. Aiming at doing it the Unity way, i created 3 prefabs for the 'tiles' and constructed a basic map to get an idea of how performant this approach might be. To give you an idea. here's the 'scene': ![scene][1] This is what would be seen during playing: ![View][2] [1]: /storage/temp/96791-big.jpg [2]: /storage/temp/96792-view.jpg
The view is around 60 fps if disabling cast shadows, so that would be very ok. I just want to know what are your thoughts about this approach? Did anyone try anything similar or has any knowledge in this area?
Thanks guys!
Answer by Cherno · Jun 29, 2017 at 01:08 AM
This approach is not feasible for all but the smallest maps. Even a tiny 16x16 tile map would mean 256 gameobjects.Instead, do it like DK and similar games did it and create a mesh ,ideally divided into chunks, which represents your tiled terrain. There are dozens of tutorials on Minecraft-style mesh generation, and a good starting point is the Mesh class Scripting API in combination of knowledge of how to use 2-dimensional arrays.
Answer by DerDicke · Jun 29, 2017 at 10:04 AM
@Cherno Thanks for your opinion. Is it based on any evidence? I'm a programmer myself and wouldn't do it this way, but wanted to try. And results are pretty good. Performance wise dynamic batching does a very good job and can keep the framerate at 60fps (see view.jpg) in the scene (big.jpg, roughly 100x100 tiles). It should be able to improve this by hierachically ordering tiles and disabling parts not visible.
Memory wise this whole build is around 40 MB, so besides textures, which are referenced, how much more can this get? 100MB for a 100x100 map? Probably not much more. Sounds ok.
Big time advantage would be that changing the tiles is an exchange of a GameObj and would happen every few seconds at maximum rate (not every frame). A very easy scheme compared to building some mesh, isn't it?
I'll have a look into your reference so far, thanks!
Your dynamic batching is only that good at the moment because your entire level appears to be created using identical cylinders that share a single, untextured material. I'm guessing your actual prefab tiles are going to have different material instances? In which case your static batching will be blown.
static batching will be out of question because 'tiles' (prefabs) must be exchangeable at runtime (your creatures will dig through dirt to create a dungeon).
Unity just can't handle the amount of gameobjects that result from having each tile or tile sperate. Especially if there also have to be resources for the actual game entities like creatures, furniture, effects, and so on.
Do you mean Unity Editor or runtime? Right, for the Editor there must be some kind of work around, for the runtime I've to see how things turn out... but according to the test above it looks like the way to go.
Be sure to test terrain alteration, too. Instantiating lots of prefab clones at the same time is also pretty resource consu$$anonymous$$g.