+1 vote

I've been working on a way to create tilemaps from a template dynamically based off a json file. Got it working decently so far, however I've run into the problem of the tilemaps (despite the nodes all being copies effectively of one another) not binding to eachother for autotile.

Have binding code (admittedly in gdscript still from tutorial I snatched it from) for autotiles within the same tilemap working...as shown between the ground-dirt and ground-stone tiles in the image below. Just not sure how to deal with the autotiling between different nodes in a 'clean' way.

Worst case alternative is being forced to create individual images/tilesets for each variant on the tiles, which I really would rather avoid for my own sanity, and keeping my file system non-bloated.

enter image description here

Godot version Godot_v3.3.2-stable_mono_x11
in Engine by (23 points)

Alright, so I spent some time messing around with the binds code (and thus converted it to C#). Thought at first I could create a global variable with the node paths in an array, for the various walls that need binding to one another. Issue #2 is there is no _Ready in the Tileset code...

Then thought that maybe I could just manually search for the corresponding walls. Issue #3, no way to use GetNode even from within the _IsTileBound.

I am honestly even more stumped then before?

1 Answer

0 votes

I did it! Or at least a semi-workaround for now...my god was this frustrating.

enter image description here

For those interested in the workaround:

   // Resets local bitmask to global template's bitmask (should be a combination of all duplicated nodes' cells):
public void ResetGlobalBitmask(Vector2 region)
    var usedTemplate = Globals.WALLTEMPLATEMAP.GetUsedCells();
    var used = GetUsedCells();
    Array[] usedIDArray = new Array[autotileID.Count];

    // First, for each autotiled ID in tileset add to array to check later:
    foreach (int id in autotileID)
        GD.Print("Reseting bitmap of " + Name + " with ID " + id + "...");
        usedIDArray[id] = Globals.WALLTEMPLATEMAP.GetUsedCellsById(id);

    // Next, scroll through the wall template region, copying it to the current wall node, then update bitmask:
    foreach (Vector2 vector in usedTemplate)
        var index = 0;
        foreach (Array cellArray in usedIDArray)
            // Checks between different autotiled tiles to set correct tile index:
            if(cellArray.Contains(vector)) SetCell((int)vector.x, (int)vector.y, (int)autotileID[index]);
    // From testing, need to reset the bitmask from outside the foreach before resetting local used cells:

    // Reset current wall node back to its own used cells (do not update the bitmask again after this, unless rerun):
    foreach (Vector2 vector in usedTemplate)
        if(!used.Contains(vector)) SetCell((int)vector.x, (int)vector.y, -1);
by (23 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 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.