Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser




Quick Information

EnhancedGridMap is a powerful plugin for Godot 4.4 that extends the functionality of the built-in GridMap node. It provides additional features for grid-based game development, including custom cell states, multi-floor support, and advanced grid manipulation tools.
EnhancedGridMap Plugin for Godot 4.4
Overview
EnhancedGridMap is a powerful plugin for Godot 4.4 that extends the functionality of the built-in GridMap node. It provides additional features for grid-based game development, including custom cell states, multi-floor support, and advanced grid manipulation tools.
Features
- Custom grid size (columns and rows)
- Multi-floor support with floor management
- Auto-generation of grid
- Custom cell states with visual representation
- A* pathfinding with diagonal movement option
- Randomization of grid cells
- Fill grid with specific cell types
- Item swapping functionality
- Editor dock for easy manipulation of grid properties
- Floor-specific operations for generating, clearing, and filling grids
Installation
- Copy the
enhanced_gridmap
folder into your Godot project'saddons
directory. - Enable the plugin in Project Settings > Plugins.
EnhancedGridMap Dock
The EnhancedGridMap Dock provides a user-friendly interface to control and manipulate the EnhancedGridMap node. Here's a detailed explanation of all features available in the dock:
Grid Properties
- Columns: Set the number of columns in the grid.
- Rows: Set the number of rows in the grid.
- Floors: Set the number of floors in your grid.
- Current Floor: Select which floor to edit.
- Auto Generate: Toggle automatic grid generation when properties change.
Grid Operations
- Generate: Manually generate the grid based on current properties.
- Clear: Remove all cells from the grid.
- Randomize: Randomly assign cell types based on defined states.
- Fill: Fill the entire grid with a specific cell type.
- Swap Items: Replace all instances of one item type with another.
Cell States
The dock allows you to define and manage custom cell states:
Default States:
- Normal
- Hover
- Start
- End
- Non-Walkable
Custom States:
- Add new states with the "Add Item State" button.
- For each state, you can set:
- Name
- ID (used in scripts to reference the state)
- Include in Randomize (toggle)
- Randomize Percentage (when included in randomization)
State Management:
- Edit existing states
- Remove custom states
- Swap items between states
Floor Management
The new floor management system allows you to:
- Add/Remove Floors: Dynamically adjust the number of floors in your grid.
- Floor Navigation: Easily switch between different floors for editing.
- Floor-Specific Operations:
- Generate specific floors
- Clear individual floors
- Fill selected floors with specific items
Item Swapping
The new item swapping feature allows you to:
- Select Source Item: Choose the item type to be replaced.
- Select Target Item: Choose the new item type to replace with.
- Swap Items: Replace all instances of the source item with the target item.
- Floor-Specific Swapping: Option to swap items only on the current floor or across all floors.
A* Pathfinding
- Start Position: Set the X and Z coordinates for the pathfinding start point.
- End Position: Set the X and Z coordinates for the pathfinding end point.
- Find Path: Calculate and visualize the path between start and end points.
- Diagonal Movement: Toggle to allow diagonal movement in pathfinding.
Visual Grid Editor
The dock includes a visual representation of the grid:
- Each cell displays its coordinates.
- Drop-down menus in each cell allow you to change the cell's state directly.
In-Depth Feature Explanation
Custom Grid Generation
The EnhancedGridMap allows for flexible grid generation:
- Auto-generation: The grid can automatically update when properties change.
- Manual generation: Use the
generate_grid()
method for custom generation logic. - Clear and regenerate: Useful for level resets or procedural generation.
Cell States
Cell states are central to the EnhancedGridMap's functionality:
- Default states: Predefined states for common use cases (normal, hover, start, end, non-walkable).
- Custom states: Create states for specific game mechanics (e.g., water, lava, ice).
- State properties:
- ID: Used in scripts to set or check cell states.
- Name: Human-readable label
- Randomize inclusion: Determine if the state should be included in randomization.
- Randomize percentage: Control the frequency of the state when randomizing.
A* Pathfinding
The integrated A* pathfinding system offers:
- Efficient pathfinding: Quickly find optimal paths between two points.
- Diagonal movement: Option to allow or disallow diagonal movement.
- Custom cost functions: Override
get_cell_cost()
for complex movement rules. - Path visualization: Easily visualize calculated paths for debugging.
Grid Manipulation
Several methods for manipulating the grid:
set_cell_from_data(x, z, item_index)
: Set a specific cell's state.fill_grid(item_index)
: Fill the entire grid with a specific state.randomize_grid()
: Randomly assign states based on defined probabilities.randomize_grid_custom(randomize_states)
: Use custom randomization rules.
Extending Functionality
The EnhancedGridMap is designed to be easily extended:
- Custom grid generation: Override
generate_grid()
for specialized layouts. - Custom pathfinding costs: Implement
get_cell_cost()
for complex movement rules. - Integration with game mechanics: Use signals like
grid_updated
to trigger game events.
Editor Integration
The plugin seamlessly integrates with the Godot editor:
- Visual editing: Manipulate the grid directly in the editor viewport.
- Real-time updates: Changes in the dock immediately reflect in the scene.
- Custom inspector: The EnhancedGridMap node has a custom inspector for easy property editing.
Plugin Usage
Basic Setup
- Add an
EnhancedGridMap
node to your scene. - Assign a
MeshLibrary
to theEnhancedGridMap
. - Use the
EnhancedGridMap
dock in the editor to configure grid properties and cell states.
Scripting
You can also interact with the EnhancedGridMap
through GDScript. Here's a basic example:
var enhanced_gridmap = $EnhancedGridMap
# Generate a 10x10 grid
enhanced_gridmap.columns = 10
enhanced_gridmap.rows = 10
enhanced_gridmap.generate_grid()
# Find a path from (0,0) to (5,5)
var path = enhanced_gridmap.find_path(Vector2(0, 0), Vector2(5, 5))
Sample Scene and Player Movement
The plugin includes a sample scene that demonstrates how to implement player movement using the EnhancedGridMap. This scene showcases pathfinding and grid-based movement.
Scene Setup
The sample scene (main.tscn
) includes:
- An
EnhancedGridMap
node with a pre-configured grid. - A player character
CharacterBody3D
with a custom script for grid-based movement. - A top-down camera for easy visualization.
Player Movement Script
The player.gd
script provides a flexible implementation of grid-based movement using the EnhancedGridMap. Key features include:
- Click-to-move functionality
- Pathfinding using the EnhancedGridMap's A* algorithm
- Smooth movement along the calculated path
- Customizable cell size and offset
- Option for diagonal movement
Usage Example
To use the player movement script in your own scene:
- Add an
EnhancedGridMap
to your scene. - Add a
CharacterBody3D
(or other suitable node) for your player. - Attach the
player.gd
script to your player node. - Set the
enhanced_gridmap_path
andplayer_path
in the inspector. - Customize other properties like
cell_size
anduse_diagonal_movement
as needed.
Here's a minimal setup example:
extends Node3D
@onready var enhanced_gridmap = $EnhancedGridMap
@onready var player = $Player
func _ready():
player.enhanced_gridmap_path = enhanced_gridmap.get_path()
player.player_path = player.get_path()
player.cell_size = Vector3(2, 2, 2)
player.use_diagonal_movement = true
This setup allows for click-to-move functionality on your EnhancedGridMap, with the player finding and following optimal paths while avoiding non-walkable cells.
API Reference
Properties
columns: int
- Number of columns in the gridrows: int
- Number of rows in the gridauto_generate: bool
- Whether to automatically generate the grid when properties changenormal_items: Array[int]
- Array of item indices for normal cells (default: [0])non_walkable_items: Array[int]
- Array of item indices for non-walkable cells (default: [4])hover_item: int
- Item index for hover state cellsstart_item: int
- Item index for pathfinding start cellsend_item: int
- Item index for pathfinding end cellsnon_walkable_item: int
- Item index for non-walkable cellsdiagonal_movement: bool
- Whether to allow diagonal movement in pathfinding
Methods
Grid Management
generate_grid()
- Generate the grid based on current propertiesclear_grid()
- Clear all cells in the gridrandomize_grid()
- Randomize cell types in the gridrandomize_grid_custom(randomize_states: Array)
- Randomize cell types based on custom statesfill_grid(item_index: int)
- Fill the entire grid with a specific item typevalidate_item_indices()
- Validate and ensure all item indices are within valid range
Property Setters
set_columns(value: int)
- Set the number of columns and update grid if auto-generate is enabledset_rows(value: int)
- Set the number of rows and update grid if auto-generate is enabledset_floors(value: int)
- Set the number of floors and update grid if auto-generate is enabledset_auto_generate(value: bool)
- Enable/disable auto-generation of grid on property changes
Cell Manipulation
set_cell_from_data(x: int, z: int, item_index: int)
- Set a specific cell's item typeget_cell_cost(x: int, z: int) -> float
- Get the cost of moving through a specific cellupdate_grid_data()
- Update the internal grid data structureupdate_cell_visual(x: int, z: int)
- Update the visual representation of a specific cell
Pathfinding
find_path(start: Vector2, end: Vector2) -> Array
- Find a path between two pointsset_diagonal_movement(enable: bool)
- Enable or disable diagonal movement in pathfindingset_point_solid(x: int, z: int, is_solid: bool)
- Set whether a point is solid (non-walkable) for pathfindinginitialize_astar()
- Initialize the A* pathfinding systemupdate_astar_costs()
- Update pathfinding costs for all cells
Signals
mesh_library_changed
- Emitted when the MeshLibrary is changedgrid_updated
- Emitted when the grid is updated
Internal Variables
current_mesh_library: MeshLibrary
- Reference to the currently assigned MeshLibrarygrid_data: Array
- 3D array storing grid data [floor][row][column]astar_by_floor: Dictionary
- Dictionary of AStar2D instances per floorpath: Array
- Stores the last calculated pathfinding path
Example Scene : Player Movement API
Here are the main properties and methods of the player movement script:
Properties
enhanced_gridmap_path: NodePath
- Path to the EnhancedGridMap nodeplayer_path: NodePath
- Path to the player nodecell_size: Vector3
- Size of each grid cellcell_offset: Vector3
- Offset applied to the player's positioncenter_x: bool
- Center the player horizontally within the cellcenter_y: bool
- Center the player vertically within the cellcenter_z: bool
- Center the player depth-wise within the celluse_diagonal_movement: bool
- Allow diagonal movement in pathfinding
Methods
find_valid_starting_position() -> Vector2i
- Find a valid starting position on the gridmove_player_to_clicked_position(grid_position: Vector2i)
- Move the player to a clicked grid positionmove_player_along_path(path: Array)
- Move the player along a calculated pathupdate_player_position(grid_position: Vector2i)
- Update the player's position based on a grid positiongrid_to_world(grid_position: Vector2i) -> Vector3
- Convert a grid position to a world position
Extending the Plugin
Custom Item States
You can add custom item states to the EnhancedGridMap:
- In the
EnhancedGridMap
dock, click the "Add Item State" button. - Set a name, ID, and randomization properties for the new state.
- Use the new state's ID when setting cell types in your scripts.
Custom Pathfinding Costs
Override the get_cell_cost
method in a script extending EnhancedGridMap to implement custom pathfinding costs:
extends EnhancedGridMap
func get_cell_cost(x: int, z: int) -> float:
var cell_item = get_cell_item(Vector3i(x, 0, z))
match cell_item:
0: return 1.0 # Normal cell
1: return 2.0 # Slow terrain
2: return 0.5 # Fast terrain
_: return INF # Non-walkable
Custom Grid Generation
You can implement custom grid generation by overriding the generate_grid
method:
extends EnhancedGridMap
func generate_grid():
clear()
for x in range(columns):
for z in range(rows):
var item_index = (x + z) % 2 # Checkerboard pattern
set_cell_item(Vector3i(x, 0, z), item_index)
update_grid_data()
initialize_astar()
update_astar_costs()
Extending the Player Movement
You can extend the player movement functionality by overriding or adding methods to the player.gd
script. For example:
Custom Movement Rules
extends "res://addons/enhanced_gridmap/examples/player.gd"
func is_valid_move(from: Vector2i, to: Vector2i) -> bool:
# Add custom logic for valid moves
var distance = from.distance_to(to)
return distance <= 1 and super.is_valid_move(from, to)
Additional Interactions
extends "res://addons/enhanced_gridmap/examples/player.gd"
func _unhandled_input(event):
super._unhandled_input(event)
if event.is_action_pressed("interact"):
interact_with_current_cell()
func interact_with_current_cell():
var cell_item = enhanced_gridmap.get_cell_item(Vector3i(current_position.x, 0, current_position.y))
# Add custom interaction logic based on cell_item
These examples demonstrate how you can build upon the provided player movement script to create more complex game mechanics that integrate seamlessly with the EnhancedGridMap plugin.
Contributing
Contributions to the EnhancedGridMap plugin are welcome! Please submit pull requests or issues on the project's GitHub repository.
License
This plugin is released under the MIT License. See the LICENSE file for details.
EnhancedGridMap is a powerful plugin for Godot 4.4 that extends the functionality of the built-in GridMap node. It provides additional features for grid-based game development, including custom cell states, multi-floor support, and advanced grid manipulation tools.
Reviews
Quick Information

EnhancedGridMap is a powerful plugin for Godot 4.4 that extends the functionality of the built-in GridMap node. It provides additional features for grid-based game development, including custom cell states, multi-floor support, and advanced grid manipulation tools.