What is the difference between magnitude and unit?

It’s in the title, what is the general difference between the two and the difference in an example like this between (EndPosition - StartPosition).Unit and (EndPosition - StartPosition).Magnitude? Are both used to calculate the distance between the two points or what?

Magnitude is used to get the length of a vector and Unit gets the direction of the Vector with a Magintude/length of 1

1 Like

The correct answer is already given by EmbatTheHybrid. If you’re interested in the maths you can read this:

1 Like

Thank you both for the information.

The easiest way for me to think about it is that Magnitude is distance or length, and Unit is direction. Multiply unit with length to get a vector with both direction and magnitude.

So your first example is to get the direction you need to travel to reach EndPosition, and the second is the distance between them. This is a good way to get the distance between a player and an object to make things like proximity doors or AoE damage. Another example is how when raycasting it is common to get the direction and multiply by a distance of your own - (EndPosition-StartPosition).Unit * 500 so you have a fixed length or range for the ray to travel.