Position.Magnitude - Position.Magnitude vs (Position - Position).Magnitude

What’s the difference between
Position.Magnitude - Position.Magnitude and (Position - Position).Magnitude

length of vector (nvm just re-read theirs literally no difference) vs distance between two vectors

There is a difference.

To clarify, a Vector3’s magnitude is pretty much the length of a vector in a number. You can learn more about it here.

You can subtract two vectors and get the magnitude and return a number in units to compare the distance between them both.

Say we have two vectors,

local vector1 = Vector3.new(-6, 0, 0)
local vector2 = Vector3.new(6, 0, 0)

One is six studs apart of 0 towards the left and another one is six studs apart from 0 to the right. The length of both vectors is 6 no matter what. But the distance between these is 12 studs apart. It completely removes the negative factor of those coordinates.

print((vector1 - vector2).magnitude) --> Prints 12
print((vector1.magnitude - vector2.magnitude)) -- Prints 0

The first option (vector1 - vector2).magnitude is the correct way to compare two Vector3’s and get the length of it. Make sure to mark this post as correct if you understand :grinning_face_with_smiling_eyes:

26 Likes