# How do I determine the distance between two points in tilemaps in unity?

If I have a tilemap with multiple layers, is there any way that Unity offers to help me infer the distance between the two points?

Also, as a related question: Are there any libraries written in C# that might also perform this logic, but without coupling to anything that might exist in Unity?

I'm specifically interested in specialized types or operations that can be performed on some kind of three dimensional array that I've loaded ahead of time.

• Are you looking for the beeline/Euclidean distance in worldspace coordinates, or in tile widths, or the hopcount using the Manhattan metric or Chebyshev metric? Apr 8, 2019 at 1:20
• I think hop count. Use my 3d grid indexes as the unit. Apr 8, 2019 at 1:34
• "I think"? Try giving a few examples of input you're giving with the desired output for each of those cases, so the question is unambiguous about what you need. Make sure to include some diagonal cases so we can tell which metric you're using (most metrics agree with one another when the separation is axis-aligned, it's only on diagonals that the differences become clear) Apr 8, 2019 at 1:41
• You're asking questions that are far above what I readily am aware of. I apologize for not knowing all that in advance, but I do find the questions informative. Apr 8, 2019 at 14:10
• Is the distance between a tile at (1, 1) and a tile at (2, 2) equal to 1 unit, √2 units, or 2 units, or some other number like 32 or 45 pixels? Which number is right for your context? If you can't tell us this, then tell us how you're trying to use the number and we'll see if we can infer what you need. Apr 8, 2019 at 14:12