Node for 3D tile-based maps.
    public class GridMap : Spatial

GridMap lets you place meshes on a grid interactively. It works both from the editor and can help you create in-game level editors.

GridMaps use a MeshLibrary which contain a list of tiles: meshes with materials plus optional collisions and extra elements.

A GridMap contains a collection of cells. Each grid cell refers to a MeshLibrary item. All cells in the map have the same dimensions.

A GridMap is split into a sparse collection of octants for efficient rendering and physics processing. Every octant has the same dimensions and can contain several cells.

Inheritance Chain

Static Fields

    public const Int32 InvalidCellItem = -1


    public GridMap()


    public bool CellCenterX { get; set; }

If true, grid items are centered on the X axis.

    public bool CellCenterY { get; set; }

If true, grid items are centered on the Y axis.

    public bool CellCenterZ { get; set; }

If true, grid items are centered on the Z axis.

    public int CellOctantSize { get; set; }

The size of each octant measured in number of cells. This applies to all three axis.

    public float CellScale { get; set; }

    public Vector3 CellSize { get; set; }

The dimensions of the grid’s cells.

    public int CollisionLayer { get; set; }

    public int CollisionMask { get; set; }

    public MeshLibrary MeshLibrary { get; set; }

The assigned MeshLibrary.

    public MeshLibrary Theme { get; set; }

Deprecated, use MeshLibrary instead.


    public void Clear()

Clear all cells.

    public void ClearBakedMeshes()

    public Godot.Collections.Array GetBakeMeshes()

    public RID GetBakeMeshInstance(int idx)

    public int GetCellItem(int x, int y, int z)

The MeshLibrary item index located at the grid-based X, Y and Z coordinates. If the cell is empty, [constant INVALID_CELL_ITEM] will be returned.

    public int GetCellItemOrientation(int x, int y, int z)

The orientation of the cell at the grid-based X, Y and Z coordinates. -1 is returned if the cell is empty.

    public float GetCellScale()

Getter for CellScale

    public Vector3 GetCellSize()

Getter for CellSize

    public bool GetCenterX()

Getter for CellCenterX

    public bool GetCenterY()

Getter for CellCenterY

    public bool GetCenterZ()

Getter for CellCenterZ

    public int GetCollisionLayer()

Getter for CollisionLayer

    public bool GetCollisionLayerBit(int bit)

    public int GetCollisionMask()

Getter for CollisionMask

    public bool GetCollisionMaskBit(int bit)

    public Godot.Collections.Array GetMeshes()

Array of Transform and Mesh references corresponding to the non empty cells in the grid. The transforms are specified in world space.

    public MeshLibrary GetMeshLibrary()

Getter for MeshLibrary

    public int GetOctantSize()

Getter for CellOctantSize

    public MeshLibrary GetTheme()

Getter for Theme

    public Godot.Collections.Array GetUsedCells()

Array of Vector3 with the non empty cell coordinates in the grid map.

    public void MakeBakedMeshes(bool genLightmapUv = false, float lightmapUvTexelSize = 0.1f)

    public Vector3 MapToWorld(int x, int y, int z)

    public void ResourceChanged(Resource resource)

    public void SetCellItem(int x, int y, int z, int item, int orientation = 0)

Set the mesh index for the cell referenced by its grid-based X, Y and Z coordinates.

A negative item index will clear the cell.

Optionally, the item’s orientation can be passed.

    public void SetCellScale(float scale)

Setter for CellScale

    public void SetCellSize(Vector3 size)

Setter for CellSize

    public void SetCenterX(bool enable)

Setter for CellCenterX

    public void SetCenterY(bool enable)

Setter for CellCenterY

    public void SetCenterZ(bool enable)

Setter for CellCenterZ

    public void SetClip(bool enabled, bool clipabove = true, int floor = 0, Vector3.Axis axis = Vector3.Axis.X)

    public void SetCollisionLayer(int layer)

Setter for CollisionLayer

    public void SetCollisionLayerBit(int bit, bool value)

    public void SetCollisionMask(int mask)

Setter for CollisionMask

    public void SetCollisionMaskBit(int bit, bool value)

    public void SetMeshLibrary(MeshLibrary meshLibrary)

Setter for MeshLibrary

    public void SetOctantSize(int size)

Setter for CellOctantSize

    public void SetTheme(MeshLibrary theme)

Setter for Theme

    public Vector3 WorldToMap(Vector3 pos)