This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+15 votes

Godot-Voxel-Game-MineCraftClone

Hello everybody,
I want to share my project: cloning Minecraft with Godot. Where I'm currently working on with you.

It's still in an pretty early phase so I still do have problems with performance and the biggest feature of Minecraft: Building and Mining is still missing ;(

Here is a screenshot of the current state:

enter image description here

For now I keep this post short but there is some more information on the github Page:

Godot-Voxel-Game-MineCraftClone

You may want to have a look at it.

in Engine by (333 points)
Like it quite a lot! You are generating chunks with gdscript or you wrote a c++ module?
Thank you. No I didn't write any c++. All chunks are generated with GDscript and the SurfaceTool. Also the voxel engine is based on dictionaries in GDscript (which is the easiest but not the most efficient way. Because GDscript dictionaries are getting really slow when there are a lot of keys in it ;( maybe I could get better results when doing it with c++)
Looking good!
I guess for every game engine there will be at least one guy to make a Minecraft clone. But that's great, it's interesting to see how Voxel games can be done with Godot and how the performance will be.
Good luck and keep us updated :)
For the voxel generation you might want to try a flat 3D byte or int array if possible and use masking and reserve bits for voxels . This should speed it up significantly.  Then like Minecraft you wanna have entities which means complex non voxel objects in a separate list.

1 Answer

+1 vote

After I read the comment of @trollworkout (THANK YOU !!!) I made some performance benchmarks with dictionaries.
I wrote a script which creates two dictionaries, one with Vectors as keys and the other one with IntArrays.
The results show how good @trollworkout's comment was!!
Here is a table of the results:

enter image description here

all numbers are in msec's
as a consequence im over 350 times faster when I use Int Arrays!!
And the creation process of the Dictionary also is going to be 640 times faster
I'm pretty shure that my test werent that proper set up but it still shows that there will be a huge performance Increase.
I will do an implementation of the new dict system as soon as possible. Shouldn't be that hard.

If somebody Is intrested or wants to give feedback here is the ugly code of the test:

extends Node

func _ready():
    var dictSize_hochDrei = 20
    var dictV = {}
    var t = OS.get_ticks_msec()


    for x in range(dictSize_hochDrei):
        for y in range(dictSize_hochDrei):
            for z in range(dictSize_hochDrei):
                dictV[Vector3(x,y,z)] = 1

    print("Vector Dict created in ",OS.get_ticks_msec() - t," msec Size: ",dictSize_hochDrei*dictSize_hochDrei*dictSize_hochDrei)


    var dictI = {}
    t = OS.get_ticks_msec()
    for x in range(dictSize_hochDrei):
        for y in range(dictSize_hochDrei):
            for z in range(dictSize_hochDrei):
                dictI[[x,y,z]] = 1

    print("Int Dict created in ",OS.get_ticks_msec() - t," msec Size: ",dictSize_hochDrei*dictSize_hochDrei*dictSize_hochDrei)

    var numberOfSearches = 200000
    var value

    var t = OS.get_ticks_msec()

    for i in range(numberOfSearches):
        var x = randi()%dictSize_hochDrei
        var y = randi()%dictSize_hochDrei
        var z = randi()%dictSize_hochDrei
        value = dictI[[x,y,z]]
    print(numberOfSearches," suchvorgaenge in _DictI_ brachten: ",OS.get_ticks_msec() - t," msec")

    var t = OS.get_ticks_msec()

    for i in range(numberOfSearches):
        var x = randi()%dictSize_hochDrei
        var y = randi()%dictSize_hochDrei
        var z = randi()%dictSize_hochDrei
        value = dictV[Vector3(x,y,z)]
    print(numberOfSearches," suchvorgaenge in _DictV_ brachten: ",OS.get_ticks_msec() - t," msec")

Small Update
I now Implemented a way to destroy blocks. This wasn't that easy and its still buggy because I have to modify a surface and can't just delete the cube that got destroyed by the player.

by (333 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.