+1 vote

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?

asked Jul 4 in Engine by Cal_9000 (15 points)

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?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.