I’m trying to make a map system for my open world space game, and I want to get the distance from one system to another. This is my test map, which uses parts as the systems you can spawn on, and the beams connecting them are “paths” you can take from one to another. For example, you can’t go from the red part to the pink part in one move, as they don’t have a connector, but you can go from the red to green to pink part.
I’m trying to make it get the distance between the parts with those constraints, and while I’ve gotten something sort of working, it’s not working as expected. For any systems that are 1 beam apart, such as the black to the blue part, it works just fine, however, it fails with a lot of systems that are more than 1 beam apart. I have an rbxl of the test map if that would be helpful. I understand this isn’t the most efficient code, but my main goal right now is just to get a working routing system. Baseplate.rbxl (21.4 KB)
local Part1 = game.Workspace.Part1 --An example of it's position would be 0,1,0
local Part2 = game.Workspace.Part2 --It's position would be 0,0,0
local Distance = (Part1.Position - Part2.Position).Magnitude --It would be 1.
Since i know that many users here in the devforum now about Magnitude, i don’t know if this is what you’re asking for .
I just did a test with that, and due to the way my paths are arranged, there doesn’t seem to be a relationship with how far away a part is in beams and how far away it is when I get all the path waypoints.