Attention | Topic was automatically imported from the old Question2Answer platform. | |
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
Ideas?
c# - Unity Coordinate Limitations and its impact - Stack Overflow
rakkarage | 2020-07-04 16:56
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
sorry not sure. hope this helps.
c# - Overcoming float limitations for planet-sized worlds in Unity - Game Development Stack Exchange
rakkarage | 2020-07-04 19:31