- Home /
How to set up a minecraft-like game?
Okay first: I'm new to Unity but not to programming. I also have already some gamedev experience and understand what matrices are etc. I don't want you to do the work for me - I'm asking here for an architectural advice, okay? ;)
I'm currently creating a minecraft-like game. That means:
The world exists out of blocks (cubes, 1x1x1)
Blocks are collected in chunks
The world is infinite
You can destroy / build blocks
You collect destroyed blocks in your inventory
..
My first attempt - which worked pretty flawless so far - was set up this way:
My World checks every update if there are enough **Chunk*s around me to see viewRange* far, if not it creates all missing chunks.
Okay now to my Problem:
A chunk consist of blocks. That means currently I texture every block from a spritesheet with an adjusted UV mapping. This works so far but this is absolutely annoying since it is hard to maintainable IMHO. But the more important reason is I want to have different materials. In the simplest case I just want to have a different material color or shader for a single block.
In more complex scenarios I want to have different physical behaviours. Imagine a sand block, that has gravity.
So what I want to do:
My World consists of a number of **Chunk*s. A Chunk consists of a number of Block*s. Every Block has his own mesh with a texture from a single material. The material is a single texture - not a spritesheet. A block can exists of one of 255 different Materials.
And my question is:
What would be a good approach to accomplish this with Unity?
I hope this question is not to offensive. As I said, I don't want you to programm my game. I'm just asking for an advice.
I went ahead and published your question in case someone has a quick and easy answer. But in general we refer design questions to Unity Forums. Unity Answers is designed to deal with single specific technical questions where multiple people attempt an answer. It is poor for design questions. Plus i think more people that can help you with this specific issue live on Unity Forums than here.
P.S. Have you explored sumeshes and the materials array? If so, have you run any performance tests?
Thanks for your answer.
Submeshes: Yes, materials array: No. After a quick google this seems pretty interesting (Even when the thread says something like "horrible performance", but you never know when you didn't tried it at least)
I understand. Would it be rude to repost this question in the forums?
I would suggest you repost it on the forums. I left it open here ins$$anonymous$$d of just closing it and sending you to the forums because there is sometimes a 'magic bullet' for a question like this one.
FYI: I've got it working with Submeshes and the material array. So far I can't notice any performance losses. Well, for now I'm happy with this solution.
Feel free to post your comment as an answer for your +1 :)
Your answer
Follow this Question
Related Questions
How Can I make random level generation? 3 Answers
Mesh overlapping and textures. 0 Answers
Destructible Meshes At Runtime? 1 Answer
How to disable self-shadowing on a mesh 0 Answers