0 votes

I'm hoping to make a voxel terrain generator similar to minecraft just as a learning experience.
I know there's a c++ module made by a dev called zylann however compiling it into the engine feels inconvenient. so i went ahead to look for other ways to do it without using 3rd party plugins/modules and i stumbled upon procedural generation using MeshInstance(s)
I tried generating a cube using ArrayMesh but i can't seem to figure out how to get the faces correctly.

here's the code i wrote:

tool
extends MeshInstance


func _ready():
    var arr = []
    arr.resize(ArrayMesh.ARRAY_MAX)

    var verts = PoolVector3Array()

    verts.append(Vector3(1, 1, 1))
    verts.append(Vector3(1, 1, -1))
    verts.append(Vector3(-1, 1, 1))
    verts.append(Vector3(-1, 1, -1))

    verts.append(Vector3(1, -1, 1))
    verts.append(Vector3(1, -1, -1))
    verts.append(Vector3(-1, -1, 1))
    verts.append(Vector3(-1, -1, -1))

    arr[ArrayMesh.ARRAY_VERTEX] = verts

    mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arr)

it'd also be appreciated if anybody suggested any approaches to applying textures to the faces of the cube

all the help is appreciated!

asked Jun 19 in Engine by izhvnter (28 points)
retagged Jun 19 by izhvnter

1 Answer

0 votes
Best answer
answered Jun 20 by izhvnter (28 points)
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 How to use this Q&A? before posting your first questions.