+1 vote

I worder if there's a way to get a autotile just like a single tile using GDScript.
Someone can help me, please?

in Engine by (17 points)

1 Answer

0 votes

There's not an official tutorial for autotile, but this may help you:

by (20,679 points)

I don't think this is what he meant to ask.
Currently, when you are trying to set tiles via code, you have to manually specify a vector representing a bitmask index required to select a sprite corresponding to autotile.
There is no way to put a sprite in the valid fashion from the very start, but what you can do, is to put all the sprites in the corresponding positions and call updatebitmaskregion after that.

Here is an example from my code:

private void InstanciateTilemap(Node scene)
        var set = GD.Load<TileSet>("res://TileSets/Default.tres");

        var map =
            new TileMap
                TileSet = set,
                CellSize = new Vector2(32, 32),
                CellQuadrantSize = 16

        var size = OS.WindowSize;

        for(var horizontalIndex = 0; horizontalIndex < 16; horizontalIndex++)
         for(var verticalIndex = 0; verticalIndex < 16; verticalIndex++)

            new Vector2(),


Source: https://github.com/godotengine/godot/issues/13960

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.