Magnitude Distance Calc Inconsistency

I just started working with magnitude for the first time, so excuse me if this is a stupid misconception

While trying to calculate distance I noticed an inconsistency in the numbers based on the direction(i.e. north, south west and east sometimes produce completely asymmetric numbers). Here is a demonstration.

The distance is being check from the part in the center, to the four other parts in each direction. They are all exactly 5 studs from the middle part. The north and south directions seem to work as intended, but I have no idea where the west and east distances are determined from.


Output:
23:25:13.347 North distance is -6 - Server - Script:6
23:25:13.347 South distance is -6 - Server - Script:7
23:25:13.347 West distance is -2 - Server - Script:8
23:25:13.347 East distance is -12 - Server - Script:9

Code in demonstration:

local calculatedDistanceNorth = game.Workspace.North.Position.Magnitude - game.Workspace.movePart.LookingPart.Position.Magnitude
local calculatedDistanceSouth = game.Workspace.South.Position.Magnitude - game.Workspace.movePart.LookingPart.Position.Magnitude
local calculatedDistanceWest = game.Workspace.West.Position.Magnitude - game.Workspace.movePart.LookingPart.Position.Magnitude
local calculatedDistanceEast = game.Workspace.East.Position.Magnitude - game.Workspace.movePart.LookingPart.Position.Magnitude
print("North distance is "..math.floor(calculatedDistanceNorth))
print("South distance is "..math.floor(calculatedDistanceSouth))
print("West distance is "..math.floor(calculatedDistanceWest))
print("East distance is "..math.floor(calculatedDistanceEast))

Please let me know if there’s a more effective way to go about this, thank you for your time

You are calculating it wrong. It should be:

local calculatedDistanceNorth = (game.Workspace.North.Position - game.Workspace.movePart.LookingPart.Position).Magnitude

and so on and so forth for the other ones.

1 Like

You are a life saver, thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.