- Home /
2D 'Voxel' Game
This might have been asked before but I couldn't find a post with the exact answer I wanted. I'm currently trying to make a game based on Terraria. I have all the rpg systems coded pretty much but just haven't finished the world as I keep changing what type of game it will be and can't make up my mind. (I would probably do 3D but I can't art soo.... 2D it is)
I've been following this tutorial about world generation: http://studentgamedev.blogspot.no/2013/08/unity-voxel-tutorial-part-1-generating.html
In the tutorial, it starts with a 2D world but with 3D meshes and colliders then transforms into a 3D game. Would the best option to be to continue with using the 3d meshes and colliders or switch everything to 2D. What would be the benefits of using 3D vs 2D? The game will fully be in 2D and no 3D elements will be needed, but for coding purposes which makes the most sense and the easiest?
Answer by tanoshimi · Aug 24, 2016 at 09:43 AM
If your game is fully in 2D, you gain no benefit from using 3D physics, and you incur extra complexity from doing so. The tutorial you are following is old, and probably dates from a time before Unity has the dedicated 2D workflow it has now. Use 2D physics and sprites all the way, and refer to one of Unity's own more up-to-date tutorials if you need to.
A "2d voxel" is a "pixel", btw.
If i had a world like:
1 = block, 0 = empty
0 0 0 1 1 0 1
1 1 1 1 1 1 1
0 1 1 0 0 0 1
1 1 1 1 1 1 1
I'll be using sprites for everything now. Now I'm deciding between EdgeColliders, BoxColliders, PolygonColliders. It seems the best would be an EdgeCollider because of performance and it fixes some ground problems but I don't think I can solely use it because of inner empty spaces or I could use a combo of Edge and Box/Poly maybe... or just go with Polygon. This would require an algorithm to find all the edges and make a big collider around the frame and have other 'paths' (like a polygon collider) $$anonymous$$gled in the collider to account for empty space.
I think the best solution is to have one collider for all the chunks that are visible to the player. I believe the best way is to do something like Greedy $$anonymous$$esh algorithm for 2D ... or just do a greedy search over the blocks and make paths by hand for the PolygonCollider. Is there any better good options?
Your answer
![](https://koobas.hobune.stream/wayback/20220612091425im_/https://answers.unity.com/themes/thub/images/avi.jpg)