Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

GridMap

Inherits: Node3D < Node < Object

Node for 3D tile-based maps.

Description

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

GridMaps use a MeshLibrary which contains a list of tiles. Each tile is a mesh with materials plus optional collision and navigation shapes.

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

Internally, 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.

Note: GridMap doesn't extend VisualInstance3D and therefore can't be hidden or cull masked based on VisualInstance3D.layers. If you make a light not affect the first layer, the whole GridMap won't be lit by the light in question.

Tutorials

Properties

bool

bake_navigation

false

bool

cell_center_x

true

bool

cell_center_y

true

bool

cell_center_z

true

int

cell_octant_size

8

float

cell_scale

1.0

Vector3

cell_size

Vector3(2, 2, 2)

int

collision_layer

1

int

collision_mask

1

float

collision_priority

1.0

MeshLibrary

mesh_library

PhysicsMaterial

physics_material

Methods

void

clear ( )

void

clear_baked_meshes ( )

RID

get_bake_mesh_instance ( int idx )

Array

get_bake_meshes ( )

Basis

get_basis_with_orthogonal_index ( int index ) const

int

get_cell_item ( Vector3i position ) const

Basis

get_cell_item_basis ( Vector3i position ) const

int

get_cell_item_orientation ( Vector3i position ) const

bool

get_collision_layer_value ( int layer_number ) const

bool

get_collision_mask_value ( int layer_number ) const

Array

get_meshes ( ) const

RID

get_navigation_map ( ) const

int

get_orthogonal_index_from_basis ( Basis basis ) const

Vector3i[]

get_used_cells ( ) const

Vector3i[]

get_used_cells_by_item ( int item ) const

Vector3i

local_to_map ( Vector3 local_position ) const

vo