GridMap

Hereda: Node3D < Node < Object

Nodo para mapas en 3D basados en tiles.

Descripción

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.

Tutoriales

Propiedades

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

Métodos

void

clear()

void

clear_baked_meshes()

RID

get_bake_mesh_instance(idx: int)

Array

get_bake_meshes()

Basis

get_basis_with_orthogonal_index(index: int) const

int

get_cell_item(position: Vector3i) const

Basis

get_cell_item_basis(position: Vector3i) const

int

get_cell_item_orientation(position: Vector3i) const

bool

get_collision_layer_value(layer_number: int) const

bool

get_collision_mask_value(layer_number: int) const

Array

get_meshes() const

RID

get_navigation_map() const

int

get_orthogonal_index_from_basis(basis: Basis) const

Array[Vector3i]

get_used_cells() const

Array[Vector3i]

get_used_cells_by_item(item: int) const

Vector3i

local_to_map(local_position: Vector3) const

void

make_baked_meshes(gen_lightmap_uv: bool = false, lightmap_uv_texel_size: float = 0.1)

Vector3

map_to_local(map_position: Vector3i) const

void

resource_changed(resource: Resource)

void

set_cell_item(position: Vector3i, item: int, orientation: int = 0)

void

set_collision_layer_value(layer_number: int, value: bool)

void

set_collision_mask_value(layer_number: int, value: bool)

void

set_navigation_map(navigation_map: RID)


Señales

cell_size_changed(cell_size: Vector3) 🔗

Emitida cuando cell_size cambia.


changed() 🔗

Emitida cuando la MeshLibrary de este GridMap cambia.


Constantes

INVALID_CELL_ITEM = -1 🔗

Elemento celular inválido que puede ser usado en set_cell_item() para borrar células (o representar una célula vacía en get_cell_item()).


Descripciones de Propiedades

bool bake_navigation = false 🔗

  • void set_bake_navigation(value: bool)

  • bool is_baking_navigation()

Si es true, este GridMap crea una región de navegación para cada celda que utiliza un elemento mesh_library con una malla de navegación. La región de navegación creada utilizará la máscara de bits de las capas de navegación asignada al elemento de MeshLibrary.


bool cell_center_x = true 🔗

  • void set_center_x(value: bool)

  • bool get_center_x()

Si es true, los elementos de la cuadrícula se centran en el eje X.


bool cell_center_y = true 🔗

  • void set_center_y(value: bool)

  • bool get_center_y()

Si es true, los elementos de la cuadrícula se centran en el eje Y.


bool cell_center_z = true 🔗

  • void set_center_z(value: bool)

  • bool get_center_z()

Si es true, los elementos de la cuadrícula se centran en el eje Z.


int cell_octant_size = 8 🔗

  • void set_octant_size(value: int)

  • int get_octant_size()

El tamaño de cada octante medido en número de celdas. Esto se aplica a los tres ejes.


float cell_scale = 1.0 🔗

  • void set_cell_scale(value: float)

  • float get_cell_scale()

La escala de los elementos de celda.

Esto no afecta al tamaño de las celdas de la cuadrícula en sí, sólo a los ítems en ellas. Esto puede ser usado para hacer que los elementos de la celda se superpongan a sus vecinos.


Vector3 cell_size = Vector3(2, 2, 2) 🔗

Las dimensiones de las celdas de rejilla.

Esto no afecta al tamaño de las mallas. Véase cell_scale.


int collision_layer = 1 🔗

  • void set_collision_layer(value: int)

  • int get_collision_layer()

Las capas físicas en las que se encuentra este GridMap.

Los GridMaps actúan como cuerpos estáticos, lo que significa que no son afectados por la gravedad u otras fuerzas. Sólo afectan a otros cuerpos físicos que colisionan con ellos.


int collision_mask = 1 🔗

  • void set_collision_mask(value: int)

  • int get_collision_mask()

The physics layers this GridMap detects collisions in. See Collision layers and masks in the documentation for more information.


float collision_priority = 1.0 🔗

  • void set_collision_priority(value: float)

  • float get_collision_priority()

La prioridad usada para resolver colisiones cuando ocurre penetración. Cuanto mayor sea la prioridad, menor será la penetración en el objeto. Esto puede usarse, por ejemplo, para evitar que el jugador atraviese los límites de un nivel.


MeshLibrary mesh_library 🔗

La MeshLibrary asignada.


PhysicsMaterial physics_material 🔗

Overrides the default friction and bounce physics properties for the whole GridMap.


Descripciones de Métodos

void clear() 🔗

Despeja todas las celdas.


void clear_baked_meshes() 🔗

Borra todas las mallas procesadas. Véase make_baked_meshes().


RID get_bake_mesh_instance(idx: int) 🔗

Returns RID of a baked mesh with the given idx.


Array get_bake_meshes() 🔗

Returns an array of ArrayMeshes and Transform3D references of all bake meshes that exist within the current GridMap. Even indices contain ArrayMeshes, while odd indices contain Transform3Ds that are always equal to Transform3D.IDENTITY.

This method relies on the output of make_baked_meshes(), which will be called with gen_lightmap_uv set to true and lightmap_uv_texel_size set to 0.1 if it hasn't been called yet.


Basis get_basis_with_orthogonal_index(index: int) const 🔗

Returns one of 24 possible rotations that lie along the vectors (x,y,z) with each component being either -1, 0, or 1. For further details, refer to the Godot source code.


int get_cell_item(position: Vector3i) const 🔗

The MeshLibrary item index located at the given grid coordinates. If the cell is empty, INVALID_CELL_ITEM will be returned.


Basis get_cell_item_basis(position: Vector3i) const 🔗

Returns the basis that gives the specified cell its orientation.


int get_cell_item_orientation(position: Vector3i) const 🔗

The orientation of the cell at the given grid coordinates. -1 is returned if the cell is empty.


bool get_collision_layer_value(layer_number: int) const 🔗

Devuelve si la capa especificada de collision_layer está habilitada o no, dado un layer_number entre 1 y 32.


bool get_collision_mask_value(layer_number: int) const 🔗

Devuelve si la capa especificada de collision_mask está habilitada o no, dado un layer_number entre 1 y 32.


Array get_meshes() const 🔗

Returns an array of Transform3D and Mesh references corresponding to the non-empty cells in the grid. The transforms are specified in local space. Even indices contain Transform3Ds, while odd indices contain Meshes related to the Transform3D in the index preceding it.


RID get_navigation_map() const 🔗

Returns the RID of the navigation map this GridMap node uses for its cell baked navigation meshes.

This function returns always the map set on the GridMap node and not the map on the NavigationServer. If the map is changed directly with the NavigationServer API the GridMap node will not be aware of the map change.


int get_orthogonal_index_from_basis(basis: Basis) const 🔗

This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index (in the range from 0 to 23) of the point best representing the orientation of the object. For further details, refer to the Godot source code.


Array[Vector3i] get_used_cells() const 🔗

Devuelve un array de Vector3 con las coordenadas de la celda no vacía en el mapa de la cuadrícula.


Array[Vector3i] get_used_cells_by_item(item: int) const 🔗

Devuelve un array de todas las celdas con el índice del ítem dado en item.


Vector3i local_to_map(local_position: Vector3) const 🔗

Devuelve las coordenadas del mapa de la celda que contiene la local_position dada. Si local_position está en coordenadas globales, considera usar Node3D.to_local() antes de pasarla a este método. Véase también map_to_local().


void make_baked_meshes(gen_lightmap_uv: bool = false, lightmap_uv_texel_size: float = 0.1) 🔗

Genera una malla procesada que representa todas las mallas en la MeshLibrary asignada para su uso con LightmapGI. Si gen_lightmap_uv es true, se generarán datos UV2 para cada malla utilizada actualmente en GridMap. De lo contrario, solo las mallas que ya tengan datos UV2 presentes podrán usar lightmaps procesados. Al generar UV2, lightmap_uv_texel_size controla la densidad de texeles para los lightmaps, con valores más bajos que dan como resultado lightmaps más detallados. lightmap_uv_texel_size se ignora si gen_lightmap_uv es false. Consulta también get_bake_meshes(), que se basa en la salida de este método.

Nota: Llamar a este método no procesará realmente los lightmaps, ya que el procesado del lightmap se realiza utilizando el nodo LightmapGI.


Vector3 map_to_local(map_position: Vector3i) const 🔗

Devuelve la posición de una celda de la cuadrícula en el espacio de coordenadas local de GridMap. Para convertir el valor devuelto en coordenadas globales, usa Node3D.to_global(). Véase también local_to_map().


void resource_changed(resource: Resource) 🔗

Obsoleto: Use Resource.changed instead.

Este método no hace nada.


void set_cell_item(position: Vector3i, item: int, orientation: int = 0) 🔗

Establece el índice de la malla para la celda referenciada por sus coordenadas de la cuadrícula.

Un índice de elemento negativo como INVALID_CELL_ITEM borrará la celda.

Opcionalmente, se puede pasar la orientación del elemento. Para ver los valores de orientación válidos, véase get_orthogonal_index_from_basis().


void set_collision_layer_value(layer_number: int, value: bool) 🔗

Basado en value, habilita o deshabilita la capa especificada en collision_layer, dado un layer_number entre 1 y 32.


void set_collision_mask_value(layer_number: int, value: bool) 🔗

Basado en value, habilita o deshabilita la capa especificada en collision_mask, dado un layer_number entre 1 y 32.


void set_navigation_map(navigation_map: RID) 🔗

Establece el RID del mapa de navegación que este nodo GridMap debe usar para sus mallas de navegación procesadas por celdas.