Global mouse position grows more inaccurate the farther away you get from 0,0

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Cal_9000

Until I move my character/camera, the following code works perfectly. but, the farther I go away from the starting point the further the mouse position drifts from where to pointer is.

extends Node2D

onready var tile = get_node("TileMap")

func get_tile(mouse_pos):
	var cell_pos = tile.world_to_map(get_global_mouse_position())
	print (cell_pos)
	return cell_pos

func _input(event):
	if event is InputEventMouseButton and event.is_pressed():
		var clicked = get_tile(event.position)
		tile.set_cell(clicked.x, clicked.y, -1)

the inaccuracy starts showing once you walk in any direction for about 2 seconds

I’m aware of this phenomena, but skeptical if that’s the issue in this case as I only need to barely move my character from the origin to experience noticeable inaccuracy.

If it is the phenomena would you have a suggestion on how to get a pointer position that doesnt deal with floats?

Cal_9000 | 2020-07-04 17:06