GridMap

    Category: Core

    Node for 3D tile-based maps.

    Properties

    void ( )
    voidclear_baked_meshes ( )
    get_bake_mesh_instance ( idx )
    Array ( )
    int ( int x, y, int z ) const
    get_cell_item_orientation ( x, int y, z ) const
    bool ( int bit ) const
    get_collision_mask_bit ( bit ) const
    Array ( )
    Array ( ) const
    voidmake_baked_meshes ( gen_lightmap_uv=false, float lightmap_uv_texel_size=0.1 )
    map_to_world ( x, int y, z ) const
    voidresource_changed ( resource )
    voidset_cell_item ( x, int y, z, int item, orientation=0 )
    voidset_clip ( enabled, bool clipabove=true, floor=0, Vector3.Axis axis=0 )
    voidset_collision_layer_bit ( bit, bool value )
    void ( int bit, value )
    Vector3 ( Vector3 pos ) const

    Constants

    • INVALID_CELL_ITEM = -1 — Invalid cell item that can be used in to clear cells (or represent an empty cell in get_cell_item).

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

    Tutorials

    Setterset_center_x(value)
    Getterget_center_x()

    • cell_center_y
    Setterset_center_y(value)
    Getterget_center_y()

    If , grid items are centered on the Y axis.


    If , grid items are centered on the Z axis.


    • int cell_octant_size
    Setterset_octant_size(value)
    Getterget_octant_size()

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


    • cell_scale
    Setterset_cell_scale(value)
    Getterget_cell_scale()

    Setterset_cell_size(value)
    Getterget_cell_size()

    The dimensions of the grid’s cells.


    • collision_layer

    • int collision_mask
    Setterset_collision_mask(value)
    Getterget_collision_mask()

    • mesh_library
    Setterset_mesh_library(value)
    Getterget_mesh_library()

    The assigned MeshLibrary.


    • theme
    Setterset_theme(value)
    Getterget_theme()

    Deprecated, use mesh_library instead.

    Method Descriptions

    • void clear ( )

    • void clear_baked_meshes ( )

    • get_bake_mesh_instance ( int idx )

    • get_bake_meshes ( )

    • int get_cell_item ( x, int y, z ) const

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


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


    • bool get_collision_layer_bit ( bit ) const

    • bool get_collision_mask_bit ( bit ) const

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


    • get_used_cells ( ) const

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


    • void make_baked_meshes ( gen_lightmap_uv=false, float lightmap_uv_texel_size=0.1 )

    • map_to_world ( int x, y, int z ) const

    • void resource_changed ( resource )

    • void set_cell_item ( int x, y, int z, 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.


    • void set_clip ( enabled, bool clipabove=true, floor=0, Vector3.Axis axis=0 )

    • void set_collision_layer_bit ( int bit, value )

    • void set_collision_mask_bit ( int bit, value )

    • Vector3 world_to_map ( pos ) const