Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
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¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Methods¶
Signals¶
cell_size_changed ( Vector3 cell_size )
Emitted when cell_size changes.
changed ( )
Emitted when the MeshLibrary of this GridMap changes.
Constants¶
INVALID_CELL_ITEM = -1
Invalid cell item that can be used in set_cell_item to clear cells (or represent an empty cell in get_cell_item).
Property Descriptions¶
If true
, this GridMap creates a navigation region for each cell that uses a mesh_library item with a navigation mesh. The created navigation region will use the navigation layers bitmask assigned to the MeshLibrary's item.
bool cell_center_x = true
If true
, grid items are centered on the X axis.
bool cell_center_y = true
If true
, grid items are centered on the Y axis.
bool cell_center_z = true
If true
, grid items are centered on the Z axis.
int cell_octant_size = 8
The size of each octant measured in number of cells. This applies to all three axis.
float cell_scale = 1.0
The scale of the cell items.
This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors.
Vector3 cell_size = Vector3(2, 2, 2)
The dimensions of the grid's cells.
This does not affect the size of the meshes. See cell_scale.
int collision_layer = 1
The physics layers this GridMap is in.
GridMaps act as static bodies, meaning they aren't affected by gravity or other forces. They only affect other physics bodies that collide with them.
int collision_mask = 1