30 lines
761 B
Markdown
30 lines
761 B
Markdown
Hexmap Settings:
|
|
![[Pasted image 20250413094820.png]]
|
|
|
|
GDScript on the layer:
|
|
```python
|
|
extends TileMapLayer
|
|
|
|
func _unhandled_input(event):
|
|
if event is InputEventMouseButton:
|
|
var mouse_pos = get_local_mouse_position()
|
|
var cell_pos = local_to_map(mouse_pos)
|
|
print("Clicked cell: ", cell_pos)
|
|
|
|
var source_id = get_cell_source_id(cell_pos)
|
|
print("source_id:", source_id)
|
|
|
|
if source_id > -1:
|
|
print("Atlas coords:")
|
|
var atlas_coords = get_cell_atlas_coords(cell_pos)
|
|
print(atlas_coords)
|
|
|
|
#Example: Place/erase tile on click
|
|
if event.button_index == MOUSE_BUTTON_LEFT:
|
|
pass
|
|
#set_cell(cell_pos, 51, Vector2i(6, 1)) # Place tile
|
|
elif event.button_index == MOUSE_BUTTON_RIGHT:
|
|
set_cell(cell_pos, -1) # Erase tile
|
|
|
|
```
|
|
|