...
This commit is contained in:
parent
ab873a6619
commit
2f4be2d317
2 changed files with 30 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
BIN
MyObsidianVault/Pasted image 20250413094820.png
Normal file
BIN
MyObsidianVault/Pasted image 20250413094820.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
Loading…
Add table
Add a link
Reference in a new issue