Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is mavnitude, where and how to use it?

Pretty self explanatory, i would like to get some more help on magnitude

5 comments

0

And also i would like to know what kind of script i should it

0

You're in luck. I wrote the above tutorial for this type of question. ;)

0

nice tutorial

0

that tutorial that phleg made is the one that inspired me to learn more about math :)

2 answers

✓ Accepted answer

Magnitude is always described as the "distance between two objects", which is totally wrong. .magnitude is a property of Vector3 (vector3, cframe and a lot of other datatypes count as an object) and magnitude simply means "length", and in other cases it might mean a quantity a size and everything that goes along that. Vectors (or we can day Vector3s as we know them in roblox) are lines that have a direction and a length, or as we said a magnitude.

Here is an example




local vector = Vector3.new(5, 2, 3)

print(vector.magnitude) --prints out around 6.16, which is the length of this vector in studs

The most common use for .magnitude is finding the distance between two things. That's by subtracting the first position from the 2nd position (positions are just vector3s of course), that subtraction should gives us another vector that describes the distance between those two positions, so technically the magnitude of that vector is the distance between those 2 vectors. Think about it's pretty simple.

local distance = (part1.Position - part2.Position).magnitude

print(distance)

And this is not the only use for magnitude, there are A LOT especially when you're dealing with math. And really, here is a great advise, there isn't always an answer to "when would I use this?", what you should do is learn this stuff, and one day when you stumble across something you don't know, you try to think of a solution for that and maybe you needed the length of a vector so you use it!

Have a good day!

2 comments

0

thanks for the indepth answer it helped

0

np!

This discussion is preserved as it was. New answers, comments, and votes are closed.