Isometric raycast offset(?)

Godot Version

Godot 4.2.1



First time here :slight_smile:
I’m trying to make a line of sight for the player using raycast and checking for each tile if there is a collision then calculate the out of sight tiles (i plan to upgrade it later but for the moment this is okay and helps me learning basics)
So when clicking a tile the raycast sets the target position to this tile BUT it weirdly adds an offset based from the origin point (0, 0) to the player

This however doesn’t make sense since i’m modifying the target and global position each time i click a cell.

So if my player is in tile (0, 0), for some reason the raycast offsets itself from the tile (-1, 0) position and use this offset for the selected tile. So the selected tile (0, 5) becomes tile (0, 6) for the raycast.
It’s probably something really dumb but i really can’t figure out why.

Some examples :

I’ve tried everything i can, modifying position, global_position checking if coordinates are correct, local tiles, etc. But everytime the problem is the same the raycast seems to add an offset, margin ? by itself

By the way here is the player node :

And the player scene :

Thanks for the help i’m really stuck and cannot understand why :cry:

Edit :
The problem seems to come from the local and global scene and their relative position

lobalMouse(112.109, 58.50679)localMouse(80.10898, 42.50679)
globalMouse local_to_map then map_to_local(112, 56)
globalMouse local_to_map (0, 6) (localMouse) - global_pos (48.10898, 26.50679)
globalMouse - global_pos(112.109, 57.50679)
raycastdata globpos: (32, 16)
raycastdata position: (0, 0)
raycastdata target: (80.10898, 42.50679)

Post the code that checks for your ray. This is just a simple problem, but it’s hard to guess what you’re doing only from pictures.