Created
November 13, 2024 02:12
-
-
Save lamarmarshall/9080f518c0672db2d12aa91c5823fc94 to your computer and use it in GitHub Desktop.
godot 4 set tiles on tile map layer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Node2D | |
| @onready var tile_map_layer: TileMapLayer = $TileMapLayer | |
| # Called when the node enters the scene tree for the first time. | |
| func _ready() -> void: | |
| pass # Replace with function body. | |
| # Called every frame. 'delta' is the elapsed time since the previous frame. | |
| func _process(delta: float) -> void: | |
| if Input.is_action_just_pressed("interact"): | |
| var mos_pos = get_global_mouse_position() | |
| var tilemap_pos: Vector2i = tile_map_layer.local_to_map(mos_pos) | |
| tile_map_layer.set_cell(tilemap_pos, 0, Vector2i(1, 0)) | |
| print(mos_pos) | |
| print(tilemap_pos) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment