I'm using Vector2.distance_to to get the distance between a MeshInstance and a KinematicBody but the results aren't as expected.
I'm using distance_to like so:
var player_global_transform = $KinematicBody.get_global_transform().origin var player_position = Vector2(player_global_transform.x, player_global_transform.z) # Here I loop through the planes and compare positions but to simplify it I'll just show # the one. var plane_global_transform = $MeshInstance.get_global_transform().origin var plane_position = Vector2(plane_global_transform.x, plane_global_transform.z) var player_distance_to_plane = player_position.distance_to(plane_position) Also I'm using Vector2s because I don't care about Y values for this calculation.
Lets say I have 9 mesh planes (240x240) in a grid and the player is standing in the middle mesh of them:
The distance from the KinematicBody and the middle square is (0, 0) as the player is right in the middle of it. Now if I move over a square to the left:
The distance returned is (240, 0) which is expected as I'm now 1 mesh plane distance away from the center of the previous mesh. Now if I extend the grid and add 3 more meshes to the left and move over to that one:
The distance is now (360, 0) instead of (480, 0) and I can't seem to figure out why. It also seems that if I add another column of plane meshes to the left and move over another square, it's still (360, 0).


