Topic was automatically imported from the old Question2Answer platform.
Asked By
xofox
I filled up a TileMap and then attached this code to try and erase it ingame.
extends TileMap
onready var map = get_node("TileMap")
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var mousePosition = Vector2()
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _process(delta):
mousePosition = get_global_mouse_position()
map.set_cellv(mousePosition, -1)
Nothing happened though after I ran it and none of the previously determined cells were changed. What am I doing wrong that is causing the cells to not change.
get_global_mouse_position() is in pixel coordinates. set_cellv() needs map coordinates. Something happened, it’s just that the tile you’re changing is way off screen.
Awesome thanks! I appreciate the answer. I thought that it wasn’t changing. Now in this other block of code still nothing seems to be happening. Wanna look over it for me? Sorry for being a hassle.