+1 vote

Hi, i want to merge some meshes and i tried something like this:

SurfaceTool surf;
MeshInstance MeshCache[16]; //filled MeshCache with some cubes

void MyMeshInstance::addMeshFromCache(int x)
{
    surf.clear();

    if (get_mesh() != NULL)
        surf.create_from(get_mesh(), 0); //get existing mesh(!?)

    // add new mesh & set it:
    set_mesh(surf.commit(MeshCache[x].get_mesh()));

    surf.clear();
}

for (int x = 0; x < 16; x++) // than do this:
    addMeshFromCache(x);

But it dont work.
If i look ingame, it only draws the last two cubes of the array.
And i dont understand why?

Is this the right way or is there a better way to do this?

thx a lot :)

in Engine by (77 points)

1 Answer

–3 votes

Use the MultimMeshInstance from Godot instead. See: https://godotengine.org/qa/19366/how-to-use-multimeshinstance

by (1,443 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.
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 webmaster@godotengine.org with your username.