diff --git a/world/grid.gd b/world/grid.gd index c24cb99..b39d05c 100644 --- a/world/grid.gd +++ b/world/grid.gd @@ -52,8 +52,8 @@ func get_world_position (location: Vector2, offset: Vector2 = Vector2.ZERO) -> V return height * Vector2.from_angle(angle) func get_location_from_world_pos(pos : Vector2): - var angle = pos.angle() - var x = floor(num_collumns * fposmod(angle, TAU) / TAU) + var angle = fposmod(pos.angle(), TAU) + var x = floor(num_collumns * angle / TAU) var height = pos.length() var y = ceil((height - ground_radius)/cell_height) return Vector2(x, y) @@ -62,7 +62,7 @@ func get_offset_from_world_pos(pos : Vector2): var angle = pos.angle() var x = fposmod(num_collumns * angle / TAU, 1) * cell_height var height = pos.length() - var y = fposmod((height - ground_radius)/cell_height, 1) * cell_height + var y = fposmod(-(height - ground_radius)/cell_height, 1) * cell_height return Vector2(x, y) func reset():